Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegEx Pattern to Split String in C++ 1

Status
Not open for further replies.

RileyCat

Programmer
Apr 5, 2004
124
0
0
US
Hi --

I am having a terrible time trying to get a regular expression defined to split a string that will look like the following . . .

Code:
SQL12345,54321SQL     
 
XXXXX,XXXXX 
 
Where X = [0-9A-Za-z] and can be repeated one or more times on each side of the delimeter (,).

The RegEx Pattern I've come up with is . . .

Code:
"([0-9A-Za-z]+)(,)([0-9A-Za-z]+)"

I only ever want one group on each side of the delimeter. I seem to be getting results that look like . . .

Code:
myStrArr[0] = "" 
myStrArr[1] = "SQL12345" 
myStrArr[2] = "," 
myStrArr[3] = "54321SQL" 
myStrArr[4] = ""

So, why am I getting the line beginning and line end (array elements 0 and 4). And, how can I fix my regex pattern so I don't get these returned?

THANK YOU!


Stay Cool Ya'll! [smile2]

-- Kristin
 
Try it without the parenthesis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top