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

Match collection problem in regular expression

I have few user inputs which I am trying to compare via MatchCollection with different patterns I have i.e

Expand|Select|Wrap|Line Numbers
  1.     string user = "\b(?:I|would|like|to|see|id|of|bought|good)\b";
  2.  
  3.  
  4. but When I am matching string 
  5.  
  6.     string pattern = "^(?=.*\bgoods?|items?|things?\b)(?=.*\bbought\b)(?=.*\bid\b)(?=.*\btest\b).*$";
  7.  
  8.     MatchCollection mat = Regex.Matches(pattern , user );
  9.  
  10.     foreach (var item in mat)
  11.     {
  12.         Console.WriteLine(item.ToString());
  13.     }
When matching the two above, the match collection only yields/collects match for (id, bought) but ignores "goods" from the first block of pattern. It seems to be ignoring **?** mentioned at the end of every word goods?|items?|things?.

Any suggestions.


Thanks
Jul 6 '14 #1
0 1131

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Johnny Lee | last post by:
Hi, I've met a problem in match a regular expression in python. Hope any of you could help me. Here are the details: I have many tags like this: xxx<a href="http://xxx.xxx.xxx" xxx>xxx xxx<a...
1
by: Don | last post by:
I've created a regular expression to match everything from the word "const" to the end of the last line that doesn't end in a space-underscore characters. i.e. ...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
6
by: Ludwig | last post by:
Hi, i'm using the regular expression \b\w to find the beginning of a word, in my C# application. If the word is 'public', for example, it works. However, if the word is '<public', it does not...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
by: python_enthu | last post by:
On Jun 27, 11:05 am, "John Salerno" <johnj...@NOSPAMgmail.comwrote: Thanks John Salerno and John Machin, I am used to perl. So I guess I am better of using re.search instead of re.match BTW,...
7
by: Chrisso | last post by:
Hi All Is it possible with the Microsoft Scripting Runtime library to get a collection of all the files in a folder that match a regular expression? That is, can I make a call through the...
6
by: Mr.SpOOn | last post by:
Hi, I'd like to use regular expressions to parse a string and accept only valid strings. What I mean is the possibility to check if the whole string matches the regex. So if I have: I can...
0
by: Lie Ryan | last post by:
On Sun, 26 Oct 2008 17:51:29 +0100, Mr.SpOOn wrote: re.compile('a*b*$') $ matches the end of a string, or in MULTILINE mode, the end of a line (right before newline) Symmetrically, ^...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.