Sign in to follow this  
Followers 0
CyberGlitch

Stringreplace Until

6 posts in this topic

Ok, my head isn't working correctly enough to figure this out. Need to find something in a string read backwards until a space and delete anything found.

Example.

Name 1234;Address 12;phone

Would want to delete out 1234; and 12; to get

Name Address phone

Can't think of a good way to do this. I know you would want to find ; and go char by char backwards making sure it's a num until a space is found then stop but have tried many things to no avail. Someone please show me the light!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

what about this way?

$test= "Name 1234;Address 12;phone"
$test = StringReplace($test,"1234;","")
$test = StringReplace($test,"12;","")
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry, I should have been more clear, the numbers are vairable and change from line to line.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ok ... understood.... what about this code:

$test= "Name 1234;Address 12;phone"
While StringInstr($test,";") > 0
   $c1 = StringInstr($test,";")
   For $x = $c1 to 1 step -1
      if StringMid($test,$x,1) = " " then ExitLoop
   Next 
   $test = StringLeft($test,$x) & StringTrimLeft($test,$c1)
Wend

msgbox(0,'test',$test)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I knew my brain stopped working after I had lunch. Works great, doesn't like working with my current script but can run seperatly and it works. I give up for today.

Thank you so very much again.

Share this post


Link to post
Share on other sites

Here is another way.

$test= "Name 1234;Address 12;phone"
$SplitLine = StringSplit($test," ")
$Length = StringLen($SplitLine[$SplitLine[0]])
$Output = StringTrimRight($Test,$Length + 1)
MsgBox(0,"Output",$Output)
Exit

red

Share this post


Link to post
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
Sign in to follow this  
Followers 0