how to find the number of tokens using regular expression?
Posted: Mon Oct 18, 2004 2:18 am
Hello
Assuming I have a sentence like so:
"Hello %1, I %3 %4 five days day ago. %5 need to talk to %6 later"
The sentence has wild cards that can be used as placeholders for actual strings which will replace the tokens.
Such replacement can yield the sentence
"Hello Jeff, I saw you five days day ago. I need to talk to you later"
The sentence above has 6 such placeholders.
Here is my question:
Given such sentence, how can I tell how many wild cards it has?
Note that the number isn't limited to 1-9 but theoretically be very high.
I tried to use split with regular expressions but I must be using the wrong regular expression (I am fairly new to them).
I would appreciate any help
Assuming I have a sentence like so:
"Hello %1, I %3 %4 five days day ago. %5 need to talk to %6 later"
The sentence has wild cards that can be used as placeholders for actual strings which will replace the tokens.
Such replacement can yield the sentence
"Hello Jeff, I saw you five days day ago. I need to talk to you later"
The sentence above has 6 such placeholders.
Here is my question:
Given such sentence, how can I tell how many wild cards it has?
Note that the number isn't limited to 1-9 but theoretically be very high.
I tried to use split with regular expressions but I must be using the wrong regular expression (I am fairly new to them).
I would appreciate any help