Valuater Posted July 7, 2005 Posted July 7, 2005 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)
Developers Jos Posted July 7, 2005 Developers Posted July 7, 2005 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.
CyberSlug Posted July 7, 2005 Posted July 7, 2005 from StringInStr docs:Returns the position of the substring..com occurs at the 14th character position within "http://domain.comxxxxxxx" Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Valuater Posted July 7, 2005 Author Posted July 7, 2005 Thanks then how would i remove the unwanted charactors from the right??? 8)
Developers Jos Posted July 7, 2005 Developers Posted July 7, 2005 Thanksthen 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.
Valuater Posted July 7, 2005 Author Posted July 7, 2005 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)
MSLx Fanboy Posted July 7, 2005 Posted July 7, 2005 That or you could do StringTrimRight(StringLen - StringInStr) Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Valuater Posted July 7, 2005 Author Posted July 7, 2005 is that a shorter routine...? and how are you getting the string length?? (from the $R_loc?) 8)
MSLx Fanboy Posted July 7, 2005 Posted July 7, 2005 from whichever variable you are modifying... Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Valuater Posted July 7, 2005 Author Posted July 7, 2005 (edited) 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 July 7, 2005 by Valuater
buzz44 Posted July 8, 2005 Posted July 8, 2005 (edited) 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 July 8, 2005 by Burrup qq
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now