Jump to content
Sign in to follow this  
CyberGlitch

Stringreplace Until

Recommended Posts

CyberGlitch

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
Jos

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                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
CyberGlitch

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
Jos

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                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
CyberGlitch

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
redndahead

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  

×