Sign in to follow this  
Followers 0
MadaraUchiha

String Split

4 posts in this topic

Hi,

I have a String Like this: 

$String = 'Numbers:1234567890Letters:abcdefghi'

Now, I want:

1) Search for the : in the String. (In this case there are 2 matches.)

2) Get the text atfer teh 1 occurence of until the second occurence. Would be in this case the green marked part.

  

$String = 'Numbers:1234567890Letters:abcdefghi'

3) Save this text in avariable for later usage.

4) Replace the green text with 'HELLO'

5) Remove the two : 's

6) Display final String in a messagebox.

Not sure how to do this without Regex? :/ How can I acomplish this with StringReplace etc?


Share this post


Link to post
Share on other sites



output:

1234567890Letters
NumbersHELLOabcdefghi

$String = 'Numbers:1234567890Letters:abcdefghi'
$Stringa = StringRegExpReplace($String, "(.*:)(.*)(:.*)","$2")
$Stringb = StringRegExpReplace($String, ":.*:","HELLO")
ConsoleWrite($Stringa & @CRLF)
ConsoleWrite($Stringb & @CRLF)

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Hey, thanks for your reply.

But I won't just c&p, I like to understand your code. Can you explain every line pls?:)

I am not so good with Regex...


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