473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with regular expression

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.
--
Marco Minerva, ma***********@gmail.com
http://blogs.ugidotnet.org/marcom

Mar 19 '07 #1
3 1310
On 2007-03-19 18:18, ma***********@gmail.com wrote:
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:]/@\\.#&]*'?

--
Erik Wikström
Mar 19 '07 #2
On Mar 19, 1:51 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
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

Mar 19 '07 #3
mlimber wrote:
On Mar 19, 1:51 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
>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,
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)
Mar 20 '07 #4

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

Similar topics

9
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
6
by: JohnSouth | last post by:
Hi I've been using a Regular expression to test for valid email addresses. It looks like: \w+(\w+)*@\w+(\w+)*\.\w+(\w+)* I've now had 2 occassions where it has rejected and email address...
3
by: Joe | last post by:
Hi, I have been using a regular expression that I don’t uite understand to filter the valid email address. My regular expression is as follows: <asp:RegularExpressionValidator...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
6
by: deepak_kamath_n | last post by:
Hello, I am relatively new to the world of regex and require some help in forming a regular expression to achieve the following: I have an input stream similar to: Slot: slot1 Description:...
14
by: Chris | last post by:
I need a pattern that matches a string that has the same number of '(' as ')': findall( compile('...'), '42^((2x+2)sin(x)) + (log(2)/log(5))' ) = Can anybody help me out? Thanks for any help!
3
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.