Yes,
But a REGEXP can parse a whole text at once. And you forgot in your example
code to include a logic to split the text for all words. And your code
should also make sure that all words are split correctly at the ending and
the beginning of a word boundry... So your code will grow quite complex very
fast. And if you handle all those special cases, then i am not sure if you
are really faster then a RegExp. Also the .NET Regexp engine is quite fast!
And I would suggest a slightly different regexp..
(en(\w){1,}g)
-will also match "whateverending" but it will only return "ending"
(Hint: use word boundrys in your match)
Another match could be "... encodingsession ..."
-"encoding"
(Hint: use lazy quantifiers... Regexp matches are greedy by default)
For a good summary of what you can do I would suggest
http://www.regular-expressions.info/quickstart.html
So much for fussing about the other regexp, and here is my own suggestion :)
\b(en(\w)*?g)
\b = beginning of a word , followed by a literal "en" , followed buy as many
"letters" as needed, and must be ending with a "g"
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ol**************@TK2MSFTNGP04.phx.gbl...
Bert,
Are this kind of not better options,
If a(0) = "j" And a(a.Length - 1) = "j" Then
At least it is 50 times quicker than Regex.
Cor
"Bert" <be****@gmail.comschreef in bericht
news:%2***************@TK2MSFTNGP06.phx.gbl...
>hi
How do I make a regex to find a word that starts en ends with a certain
letter. What is in between is random.
thanks
b