-
February 15th, 2016, 08:51 AM
#1
Extract contents from a string using RegEX
Hello.
I have a big string , with this line specifically:
/CIP3AdmSeparationNames [(Cyan)(Magenta)(Yellow)(Black)(PANTONE 647 C)] def
I'm trying to extract ONLY the contents between Parentheses from that string with regex - but not being able to, tried a lot of combinations but none of 'em worked.
Tried using this:
Regex regex5 = new regex ("CIP3AdmSeparationNames [[]\(([^)]*)\)")
But no matches have been found.
The string has many lines - i just need this content. I don't wanna use .Indexof or .Substring - they were giving me bugs all the time.
Thanks in advance for any help !
Using latest Visual Studio and .NET
-
February 16th, 2016, 03:28 PM
#2
Re: Extract contents from a string using RegEX
Have you tried any of the online regex testers? Search bing or google for "online regex tester"
-
February 19th, 2016, 04:07 PM
#3
Re: Extract contents from a string using RegEX
You say you do not want to use Substring and IndexOf because they were giving you bugs all the time, but want to dive in with Regex ( which is much more complicated and, IMHO unnecessary ) ? That is like swimming in the ocean eventhough you only have swimming floaties..
Sorry for sounding crass, but I would suggest figuring out the Substring and IndexOf functions first. Strangely enough, these two functions are actually all you need. OK, perhaps a little bit more, but the need for RegEx is simply redundant.
Have a look here: https://msdn.microsoft.com/en-us/lib...or=-2147217396
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|