473,395 Members | 1,379 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,395 software developers and data experts.

Regex - Combining statements

I am trying to create one RegEx pattern, something like,
\s*(?<typename>\S*){1}\s*(?<varname>\S*){1}\s*[;|=]{1}\s*(?<varvalue>.*)[;]*
out of the following 2 expressions and am not having much luck.

Expressions
-----------------------------
(?<typename>\S*){1}\s*(?<varname>\S*){1}\s*[;]{1}
(?<typename>\S*){1}\s*(?<varname>\S*){1}\s*=\s*(?< varvalue>.*)[;]
Text to parse
-----------------------------
public type.subtype _myvar =data.subdata;
private int v;
private int x=5;
Expected output
-----------------------------

typename varname varvalue
============================================
type.subtype _myvar data.subdata
int v
int x 5
Any help is appreciated.
Dave
May 26 '06 #1
1 1941
Dave wrote:
I am trying to create one RegEx pattern, something like,
\s*(?<typename>\S*){1}\s*(?<varname>\S*){1}\s*[;|=]{1}\s*(?<varvalue>.*)[;]*
out of the following 2 expressions and am not having much luck.


You don't need to specify {1}, thats the default.
You don't need [;], just use ; for single characters.

Try that, looks like it does it (for the provided samples):

(?<typename>\S+)\s*(?<varname>\S+?)\s*(=\s*(?<varv alue>.*?))?\s*;

hth,
Max
May 26 '06 #2

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

Similar topics

1
by: David | last post by:
I need to write a regular expression to group lines of text separated by a blank line. Ex. Input: line1 line2 line3
6
by: Xah Lee | last post by:
how to represent the unicode "em space" in regex? e.g. i want do something like this: fracture=re.split(r'\342371*\|\342371*',myline,re.U) Xah xah@xahlee.org ∑ http://xahlee.org/
2
by: george lewycky | last post by:
Hi everyone How can I have 2 or more SQL statements run sequentially. This is needed to synchronize a reference table which is later used in a PL/SQL program that I wrote also. I'm trying...
9
by: Christ | last post by:
Hi there, i'm trying to make a regex, but it ain't working. In just one regex expression I want to check a password that must meet following requirements: - at least 6 characters long - at...
3
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I...
2
by: SomeDude | last post by:
Lo group, I am wondering if there is a way of combining two SELECT statements into a single query. Here's the obligatory example to clarify things: SELECT id WHERE name=mike SELECT bills...
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...
1
by: jason | last post by:
I have following two regex expressions. I am trying to match in the event that *EITHER* is found - combining with an OR. However, I can't seem to get the syntax right. Dim regexp2 as Regex = New...
5
by: Lance Hoffmeyer | last post by:
Hey all, in perl I was able to use the same regular expression multiple times changing one part of it via a previously defined array and put the results into a new array IN PERL: my @targets =...
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: 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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.