Jump to content

Stringreplace Until


Recommended Posts

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!

Link to comment
Share on other sites

  • Developers

what about this way?

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

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

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

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

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

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...