473,491 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

regex expressions

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
Dec 23 '06 #1
7 1148
"Bert" <be****@gmail.comwrote in news:#7kvRVjJHHA.320
@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

You can try this:

(en(\w){1,}g)

This will find en with one one or more letters in between and ending in g.

i.e. ending, encoding, encrypting, etc.
Dec 23 '06 #2
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

Dec 23 '06 #3
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

Dec 23 '06 #4
EDIT: Ignore my 2nd "Hint"

I had another example 1st and i forgot to remove the line ;)

"rdrunner" <No**@your.comwrote in message
news:OD**************@TK2MSFTNGP06.phx.gbl...
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

Dec 23 '06 #5
rdrunnner,

My meaning was telling not to use it, but think twice if there is not a more
simpler solution.

I see now that it could be understand wrong.
Cor

"rdrunner" <No**@your.comschreef in bericht
news:OD**************@TK2MSFTNGP06.phx.gbl...
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


Dec 23 '06 #6
doh,

My meaning was not telling: "not to use it" but to think think twice if
there is not a more simpler sollution.

Cor

"Cor Ligthert [MVP]" <no************@planet.nlschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
rdrunnner,

My meaning was telling not to use it, but think twice if there is not a
more simpler solution.

I see now that it could be understand wrong.
Cor

"rdrunner" <No**@your.comschreef in bericht
news:OD**************@TK2MSFTNGP06.phx.gbl...
>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


Dec 23 '06 #7
"Cor Ligthert [MVP]" <no************@planet.nlwrote in
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.
RegEx is elegant and extendable - it's built for text parsing.

Dec 23 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2961
by: Johnny | last post by:
I need to determine whether a text box contains a value that does not convert to a decimal. If the value does not convert to a decimal, I want to throw a MessageBox to have the user correct the...
17
3940
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
5
1586
by: Kijak | last post by:
Hi, Im just starting working with REGEX and got a few problems. Could you tell me how to test if two strings can be found in another. ei: String to test: "This is a great car you got" Look...
8
1808
by: vbmark | last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this. I want to know if a string contains two minus signs "-". If there are two then I want it to return TRUE. I also need to know if the...
5
1756
by: lgbjr | last post by:
Hello All, I have the following type of string: "X:Y\Z.exe" "123" What I need is an array of strings with the information from within each set of quotes. I was trying to use a Regex.Split, but...
2
1281
by: Art | last post by:
Hi & help, I'm trying to parse arithmetic expressions such as 4*(7-2.1). The first thing I'm trying is to add spaces to get: 4 * ( 7 - 2.1 ). I thought that Regular Expressions would be the...
7
2217
by: Mike Labosh | last post by:
I have the following System.Text.RegularExpressions.Regex that is supposed to remove this predefined list of garbage characters from contact names that come in on import files : Dim...
3
3007
by: a | last post by:
I'm a newbie needing to use some Regular Expressions in PHP. Can I safely use the results of my tests using 'The Regex Coach' (http://www.weitz.de/regex-coach/index.html) Are the Regular...
1
1514
by: Terry Olsen | last post by:
I download xml logs from several servers every day and read the data out of them using the XmlTextReader. But about 10% of them each day throw exceptions because they are not well formed. I don't...
15
50130
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.