473,320 Members | 2,180 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,320 software developers and data experts.

Using Regex to parse string.

KK
Dear All
I have a string like this:
myOutput = myObject.MyMethod(myInput1,myInput2)
I would like to parse this string and separate it into 4 groups.
group1 contains left of '='.
group2 contains right of '=' and left of '.'
group3 contains right of '.' and left of '('...and so on.

I'm not expert in using Regular expressions.
Can some body help me how do I achieve this using Regex class?

Thanks a lot in advance.
Krishna Rao K Krishna Rao K Lucid Software Ltd 104, NSIC STP Complex |
Guindy Industrial Estate | Ekkattuthangal | Chennai 600032 ' +91 44 2225
2273 / 76 , +91 98407 28998
Jan 17 '08 #1
2 5895
KK wrote:
Dear All
I have a string like this:
myOutput = myObject.MyMethod(myInput1,myInput2)
I would like to parse this string and separate it into 4 groups.
group1 contains left of '='.
group2 contains right of '=' and left of '.'
group3 contains right of '.' and left of '('...and so on.

I'm not expert in using Regular expressions.
Can some body help me how do I achieve this using Regex class?

Thanks a lot in advance.
Krishna Rao K Krishna Rao K Lucid Software Ltd 104, NSIC STP Complex |
Guindy Industrial Estate | Ekkattuthangal | Chennai 600032 ' +91 44 2225
2273 / 76 , +91 98407 28998

"^(?<g1>[^=]*)=(?<g2>[^.]*).(?<g3>.*)$"

This will give you three groups, g1 - g3, containing what you wanted.
This is a simplistic view of your criteria. If you need to automatically
strip out whitespace at the start/end of each group, you will need more
regex code.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jan 17 '08 #2
KK
Thank you very much Mr.Karlsen

"Lasse Vågsæther Karlsen" <la***@vkarlsen.nowrote in message
news:u3**************@TK2MSFTNGP05.phx.gbl...
KK wrote:
>Dear All
I have a string like this:
myOutput = myObject.MyMethod(myInput1,myInput2)
I would like to parse this string and separate it into 4 groups.
group1 contains left of '='.
group2 contains right of '=' and left of '.'
group3 contains right of '.' and left of '('...and so on.

I'm not expert in using Regular expressions.
Can some body help me how do I achieve this using Regex class?

Thanks a lot in advance.
Krishna Rao K Krishna Rao K Lucid Software Ltd 104, NSIC STP Complex |
Guindy Industrial Estate | Ekkattuthangal | Chennai 600032 ' +91 44 2225
2273 / 76 , +91 98407 28998

"^(?<g1>[^=]*)=(?<g2>[^.]*).(?<g3>.*)$"

This will give you three groups, g1 - g3, containing what you wanted. This
is a simplistic view of your criteria. If you need to automatically strip
out whitespace at the start/end of each group, you will need more regex
code.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3

Jan 17 '08 #3

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

Similar topics

8
by: laredotornado | last post by:
Hi, I'm using PHP 4 and trying to parse through HTML to look for HREF attributes of anchor tags and SRC attributes of IMG tags. Does anyone know of any libraries/freeware to help parse through...
3
by: Vidar Skjelanger | last post by:
I have a regex for matching VB6-functions, but it hangs on one specific function. The regex: ...
5
by: Bob | last post by:
I think this is very simple but I am having difficult doing it. Basically take a comma separated list: abc, def, ghi, jk A list with only one token does not have any commas: abc The first...
3
by: Michael D Murphy | last post by:
Hi, I would like to know how to use Regular Expressions to iteratively return and print the items between the colons in the following string to say the console.. Any help would be appreciated....
4
by: JS | last post by:
I am writing a C# app that needs to parse a sentence entered by the user for a simple boolean search. I need to capture all of the AND words that are not inside of double quotes. However, I am...
8
by: Mike9900 | last post by:
I need to get 00021 in "00sddsd00021dsd" and then increment it to become "00sddsd00022dsd". Is there a way? -- Mike
11
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend...
4
by: CJ | last post by:
Is this the format to parse a string and return the value between the item? Regex pRE = new Regex("<File_Name>.*>(?<insideText>.*)</File_Name>"); I am trying to parse this string. ...
3
by: =?Utf-8?B?TWFya19C?= | last post by:
The following is working for me but I want to include numbers in scientific notation. public double Evaluate( string expr ) { const string Num = @"(\-?\d+\.?\d*|\-?\.\d+)" Regex reMulDiv = new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.