|
-
Apr 22nd, 2004, 08:58 AM
#1
Thread Starter
Member
Regular Expression questions
I have three doubt:
1. In the next expresion: (?<desc>\w+) , how can i save in "desc" all the word fitting the expresion, for example with the next source: "Hallo ich bin ich" it should keep the hole string but it only has "Hallo".
2. How can i do an if statment with regular expresion. I have a string that could have a number or not, in the event of no number exist the string "" is asigned and i get always a cast exception, i have tried something like this:
(?(\d2)(?<status>\d2)|0)
3. How can i count the number of time that has appeared an expresion ?
Thanks,
Álvaro
-
May 5th, 2004, 01:09 PM
#2
Fanatic Member
Re: Regular Expression questions
Originally posted by leazfe
I have three doubt:
1. In the next expresion: (?<desc>\w+) , how can i save in "desc" all the word fitting the expresion, for example with the next source: "Hallo ich bin ich" it should keep the hole string but it only has "Hallo".
Simply do not use (? .... ) because using (? will not return the match.
use (<desc>\w+) instead.
You find it then either in the match on in the submatches collection.
2. How can i do an if st
atment with regular expresion. I have a string that could have a number or not, in the event of no number exist the string "" is asigned and i get always a cast exception, i have tried something like this:
(?(\d2)(?<status>\d2)|0)
3. How can i count the number of time that has appeared an expresion ?
dim matchcol as matchcollection
set matchcol=regexp.execute(mytext)
number of matches = matchcol.count i think
Thanks,
Álvaro
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|