Thanks zwei - but that doesn't really help me? How does that fit into my example?
Main Topics
Browse All TopicsHi
I originally had a problem, which was solved:
I needed to split a string based on a ( ' ) character, but only when the character was not preceded by a ( ? ) character. In otherwords it would not split / match when the ( ?' ) characters were encountered. This worked fine as seen in the example code and result
Now, my requirement has grown to not only include ( ' ) characters but also ( + ) and ( : ) characters.
So it should match / split when ( ' ) or ( + ) or ( : ) is encountered, but not ( ?' ) or ( ?+ ) or ( ?: )
How do I combine this into one regular expression.
I'm pretty sure its gonna be a quick change to the expression below - I'm just not sure how!
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi again djcheeky,
Assuming I understand the C# escaping rules, which I don't, try this:
String originalString = "UCM+123+?'home goods?''UCM+456+workgoods'
Regex reg = new Regex("(?<!\\?)[\':\+]");
string[] results = reg.Split(originalString);
foreach (string match in results)
{
Console.WriteLine(match);
}
though,
[':+] may work (it does in perl inside a char set, not sure about C#)
still don't understand why C# would require the \\? rather than just \? but if it works for you, it's all good
Hi Climbgunks! :)
I actually tried that using zwei's suggestion.
The problem is, if i execute it for this string:
String originalString = "UCM+123:?'home goods?''UCM+456?:workgoods
I get this output (minus the [ ] brackets - just for clarity):
[UCM]
[123]
['home goods']
[UCM]
[456?:workgoods]
[10?+234]
Can you see that the [ ?: ] and the [ ?+ ] are preserved, yet the [ ?' ] is replaced with [ ' ] (the ? character was removed) as seen in the line ['home goods'] which should be [?'home goods?']
Is there maybe somthing with the single quote that is required?
Thanks
Aaah - my apologies. It was indeed correct!
STUPID MISTAKE on my side - I had modified my example from:
Console.WriteLine("[" + match.Trim() + "]");
to
Console.WriteLine("[" + match.Trim().Replace("?'",
for another example I was busy with! I'm a bloody fool!!
Gonna split the points because had I not been moron, Zwei's example would have worked too initially.
Business Accounts
Answer for Membership
by: zweiPosted on 2009-06-05 at 02:51:03ID: 24554762
Select allOpen in new window