Help with regular expression

M

marco.minerva

Hi!

I have the following regular expression, that matches any word with
number and letter:

[[:alnum:]]+-?[[:alnum:]/@\\.#&]*'?

Now I must modify it so that also the word with a "_" inside are
accepted. For example:

As_for
From_now_on
For_example

Can you help me?
Thanks in advance.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Hi!

I have the following regular expression, that matches any word with
number and letter:

[[:alnum:]]+-?[[:alnum:]/@\\.#&]*'?

Now I must modify it so that also the word with a "_" inside are
accepted. For example:

As_for
From_now_on
For_example

Can you help me?
Thanks in advance.

This is really off-topic here, since there are no regex in (the current)
C++ standard, you should ask these kinds of questions in a forum for the
library you used for regexes. Having said that I think you can get it to
do what you want with one of the following (I'm no expert at regex and I
don't recognize the flavour so I give no guarantees):

[[:alnum:]]+(-|_)?[[:alnum:]/@\\.#&]*'?

[[:alnum:]]+[-_]?[[:alnum:]/@\\.#&]*'?
 
M

mlimber

This is really off-topic here, since there are no regex in (the current)
C++ standard, you should ask these kinds of questions in a forum for the
library you used for regexes.

TR1 does include include a regex library, and FAQ 5.9 says questions
are on-topic if they can be answered by looking at the standard or
"planned extensions and adjustments" to it. So I'd say both the
question and your answer are on-topic.

Cheers! --M
 
P

Pete Becker

mlimber said:
TR1 does include include a regex library,

As does C++0x.

and FAQ 5.9 says questions
are on-topic if they can be answered by looking at the standard or
"planned extensions and adjustments" to it. So I'd say both the
question and your answer are on-topic.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top