Jump to content

String in string right... question


Recommended Posts

why does this noted line ";" return 14 ???

$test = "xxxxxxhttp://domain.comxxxxxxx"

$L_loc = StringInStr($test, "http")

$result = StringTrimLeft( $test, $L_loc -1)
MsgBox(0,"test", "final result = " & $result)

$R_loc = StringInStr($result, ".com", 0, -1); here the problem... shows as 14  ???
MsgBox(0,"test", "final result = " & $R_loc)

$result_2 = StringTrimRight( $result, $R_loc -7)

MsgBox(0,"test", "final result = " & $result_2)

??????

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Developers

why does this noted line ";" return 14 ???

$test = "xxxxxxhttp://domain.comxxxxxxx"

$L_loc = StringInStr($test, "http")

$result = StringTrimLeft( $test, $L_loc -1)
MsgBox(0,"test", "final result = " & $result)

$R_loc = StringInStr($result, ".com", 0, -1); here the problem... shows as 14  ???
MsgBox(0,"test", "final result = " & $R_loc)

$result_2 = StringTrimRight( $result, $R_loc -7)

MsgBox(0,"test", "final result = " & $result_2)

??????

8)

<{POST_SNAPBACK}>

Because ".com" start at pos 14 when you first remove "xxxxxx" ....

The -1 only means to start the search from right to left, but it still returns the found position from the Left...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Thanks

then how would i remove the unwanted charactors from the right???

8)

<{POST_SNAPBACK}>

any of these functions: StringLeft() or StringTrimRight()

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

any of these functions: StringLeft() or StringTrimRight()

<{POST_SNAPBACK}>

got it ..... thanks

$test = "xxwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxhttp://my-domain.comxxxxxssssssssssssssssssssssxx"

$L_loc = StringInStr($test, "http")

$result = StringTrimLeft( $test, $L_loc -1)

$R_loc = StringInStr($result, ".com", 0, -1)

$result_2 = StringLeft( $result, $R_loc +3)

MsgBox(0,"test", "final result = " & $result_2)

8)

NEWHeader1.png

Link to comment
Share on other sites

the position and the length of the "name.com" is unknown

$test = "xxwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxhttp://my-domain.comxxxxxssssssssssssssssssssssxx"

$L_loc = StringInStr($test, "http")

$result = StringTrimLeft( $test, $L_loc -1)

$R_loc = StringInStr($result, ".com", 0, -1)

$result_2 = StringLeft( $result, $R_loc +3)

MsgBox(0,"test", "final result = " & $result_2)

I know this is your area, could you give a little more detail

8)

PS did you notice the rock radio post? (removed min/max)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I think you need to be more specific with what your hoping to achieve. A few questions...

Does the "xxwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxx" on either side of the address always have the same/same amount of characters?

Are you looking to retrieve "name.com" or the full address eg "http://name.com"?

Edit: Made a small script based on the information currently given. It relies upon having "http://" and ".com" in the string.

$Test = "xxwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxhttp://my-domain.comxxxxxssssssssssssssssssssssxx"

$Len = StringLen($Test)

$PosStart = StringInStr($Test, "http://")
$PosEnd = StringInStr($Test, ".com")

If $PosStart <> 0 Then
   $Left = StringTrimLeft($Test, $PosStart - 1)
EndIf

If $PosEnd <> 0 Then
   $Result = StringTrimRight($Left, $Len - ($PosEnd + 3))
EndIf

MsgBox(0,"",$Result)
Edited by Burrup

qq

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...