Regular expression - It should be easy, but I am having a bad time 
Author Message
 Regular expression - It should be easy, but I am having a bad time

Which patrn can I use to extract only the "myuser1" from the string
"username:myuser1" ?

Read Text:
Domain....:Test
username...:myUser1
folder........:hello

....
oPatrn = "username:(S\+)"  'This pattern identifies the string
username.....:myUser1. I want to strip it off and get only "myuser1

RegExpTest (oPatrn,oStrng)

Function RegExpTest(patrn, strng)
Dim Match
Dim Matches
Dim regEx

 Set regEx = New RegExp
 regEx.Pattern = patrn
 regEx.IgnoreCase = True
 regEx.Global = True

 Set Matches = regEx.Execute(strng)
 For Each Match in Matches
            WScript.echo Match
 Next

End Function



Sat, 09 Oct 2004 12:08:45 GMT  
 Regular expression - It should be easy, but I am having a bad time
Right(str, Instr(str, ":"))

surely? (or as near as makes no difference)

Atrax - MVP [Microsoft Most Valued Professional]

http://www.infinitemonkeys.ws/

Host with me for $100 a year!
http://www.atrax.ws/hosting/

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sat, 09 Oct 2004 12:50:38 GMT  
 Regular expression - It should be easy, but I am having a bad time
Can I offer a slight mod on that?

RIGHT(string, # of character) correct?

INSTR(str, # of characters in from LEFT)

So, RIGHT(str, Len(str) - Instr(str, ":")) ?

It's early, so there may be a 'tweak' of -1 or something on that second
part.


Quote:
> Right(str, Instr(str, ":"))

> surely? (or as near as makes no difference)

> Atrax - MVP [Microsoft Most Valued Professional]

> http://www.infinitemonkeys.ws/

> Host with me for $100 a year!
> http://www.atrax.ws/hosting/

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Sat, 09 Oct 2004 19:48:54 GMT  
 Regular expression - It should be easy, but I am having a bad time
Thanks... would regular expressions not present better performance than
Instr and/or Mid method ? That's why I was trying to use that :-)


Quote:
> Which patrn can I use to extract only the "myuser1" from the string
> "username:myuser1" ?

> Read Text:
> Domain....:Test
> username...:myUser1
> folder........:hello

> ....
> oPatrn = "username:(S\+)"  'This pattern identifies the string
> username.....:myUser1. I want to strip it off and get only "myuser1

> RegExpTest (oPatrn,oStrng)

> Function RegExpTest(patrn, strng)
> Dim Match
> Dim Matches
> Dim regEx

>  Set regEx = New RegExp
>  regEx.Pattern = patrn
>  regEx.IgnoreCase = True
>  regEx.Global = True

>  Set Matches = regEx.Execute(strng)
>  For Each Match in Matches
>             WScript.echo Match
>  Next

> End Function



Sun, 10 Oct 2004 00:06:33 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. I am having trouble executing a .exe file on the server

2. Help Guys I am Stuck Real Bad

3. Newbie: Am I that bad?

4. BAD DLL calling conventions - What am I doing wrong

5. I am trying to update a record, i am not using data control

6. I am using the Compare MS Project COM Program and having issues

7. Questions I am Having Trouble With

8. I am learning VB.NET and am wondering....

9. I am having problems with addnew

10. I am having trouble with bitblt

11. Help!!I am having VB homework problem...

12. Help: I am having trouble with sendkeys

 

 
Powered by phpBB® Forum Software