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

regex doesn't match expression

Hi,
I have an input string :
<NEW>g04 8/1 0<catset>pub=g04</catset>
and I use this regex expresssion to match from <NEWto </catset>, I
wrote:
<NEW>.+?</catsetbut it doesn't work, no match !
What is the good way ?
Thanks.

Sam

Jun 27 '08 #1
3 1564


<sk*****@gmail.comwrote in message
news:b2**********************************@59g2000h sb.googlegroups.com...
Hi,
I have an input string :
<NEW>g04 8/1 0<catset>pub=g04</catset>
and I use this regex expresssion to match from <NEWto </catset>, I
wrote:
<NEW>.+?</catsetbut it doesn't work, no match !
What is the good way ?
Thanks.

Sam
Depends on if you want the contents (in between NEWand </) or match the
tags as well? Do you want captures?

Here are a couple of solutions:

Solution #1: this is a full match of what you asked for....
\<NEW\>.@\</catset\>

Solution #2: this is a full match with 2 captures. If you would like to see
the reason for this, use the Replace with text in the Quick Replace dialog:

Find expression:
\<NEW\>{.*}\<catset\>{.*}\</catset\>

Replace with expression:
NEW: "\1"\nCATSET: "\2"

Do either of these find expressions solve your problem?

HTH,
Mythran
Jun 27 '08 #2
On Jun 19, 12:37 am, "Mythran" <Myth...@community.nospamwrote:
<skne...@gmail.comwrote in message

news:b2**********************************@59g2000h sb.googlegroups.com...
Hi,
I have an input string :
<NEW>g04 8/1 0<catset>pub=g04</catset>
and I use this regex expresssion to match from <NEWto </catset>, I
wrote:
<NEW>.+?</catsetbut it doesn't work, no match !
What is the good way ?
Thanks.
Sam

Depends on if you want the contents (in between NEWand </) or match the
tags as well? Do you want captures?

Here are a couple of solutions:

Solution #1: this is a full match of what you asked for....
\<NEW\>.@\</catset\>

Solution #2: this is a full match with 2 captures. If you would like to see
the reason for this, use the Replace with text in the Quick Replace dialog:

Find expression:
\<NEW\>{.*}\<catset\>{.*}\</catset\>

Replace with expression:
NEW: "\1"\nCATSET: "\2"

Do either of these find expressions solve your problem?

HTH,
Mythran
I'm not sure what the problem is. The following prints "found"

string s = "<NEW>g04 8/1 0<catset>pub=g04</catset>";
if (Regex.IsMatch(s, "<NEW>.+?</catset>")) {
Console.WriteLine("found");
}

Brian
Jun 27 '08 #3
On 19 juin, 09:07, kodehoved <afk...@gmail.comwrote:
On Jun 19, 12:37 am, "Mythran" <Myth...@community.nospamwrote:
<skne...@gmail.comwrote in message
news:b2**********************************@59g2000h sb.googlegroups.com...
Hi,
I have an input string :
<NEW>g04 8/1 0<catset>pub=g04</catset>
and I use this regex expresssion to match from <NEWto </catset>, I
wrote:
<NEW>.+?</catsetbut it doesn't work, no match !
What is the good way ?
Thanks.
Sam
Depends on if you want the contents (in between NEWand </) or match the
tags as well? Do you want captures?
Here are a couple of solutions:
Solution #1: this is a full match of what you asked for....
\<NEW\>.@\</catset\>
Solution #2: this is a full match with 2 captures. If you would like to see
the reason for this, use the Replace with text in the Quick Replace dialog:
Find expression:
\<NEW\>{.*}\<catset\>{.*}\</catset\>
Replace with expression:
NEW: "\1"\nCATSET: "\2"
Do either of these find expressions solve your problem?
HTH,
Mythran

I'm not sure what the problem is. The following prints "found"

string s = "<NEW>g04 8/1 0<catset>pub=g04</catset>";
if (Regex.IsMatch(s, "<NEW>.+?</catset>")) {
Console.WriteLine("found");
}

Brian
Yes Brian you are right, my sample code match the searched string.
I was using a tool for testing and it was not work for a unknown
reason.
Thanks for help.
Sam
Jun 27 '08 #4

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

Similar topics

2
by: Sriram | last post by:
Hi, I am having trouble matching a regex that combines a negated character class and an anchor ($). Basically, I want to match all strings that don't end in a digit. So I tried: ...
5
by: Aaron C | last post by:
Hi, I'm trying to do an insert with the following statement: INSERT INTO user VALUES ( 'ag@ag.com','ag','Aaron','Chandler','','','La Mirada','CA',90638,714,'',''); and I'm getting the error...
1
by: Radioflyer651 | last post by:
I'm stumped... I'm trying to find start and stop blocks in a string which use the same markers. The problem is that it finds the very first start marker and very last end marker and counts only...
4
by: Garibaldi | last post by:
Folks, I'm having a bad regex day and can sure use your help, please.. I have a Regex expression that works fine. It's purpose is to isolate all data from the start of a string begining with...
0
by: tania | last post by:
i have this table in my database: CREATE TABLE FILM( F_ID INT(5) NOT NULL AUTO_INCREMENT, F_TITLE VARCHAR(40) NOT NULL, DIRECTOR_FNAME VARCHAR(20) NOT NULL, DIRECTOR_LNAME VARCHAR(20) NOT NULL,...
4
by: Chris | last post by:
Hi Everyone, I am using a regex to check for a string. When all the file contains is my test string the regex returns a match, but when I embed the test string in the middle of a text file a...
5
by: Gilles Ganault | last post by:
Hello I'm trying to extract information from a web page using the Re module, but it doesn't seem to support MULTILINE: ============= import re #NO CRLF : works response =...
12
by: cmk128 | last post by:
Hi PHP's regular expression look like doesn't support .*? syntax. So i cannot match the shortest match. For exmaple: $str="a1b a3b"; $str1=ereg_replace("a.*b", "peter", $str1); will produce...
3
by: mkjame | last post by:
Hi everyone! I am actually coding a php script and I want to return all the values that doesn't have a relation between two tables. Basically I have two tables, one is called users, the other...
1
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.