Hi,
Im just starting working with REGEX and got a few problems. Could you
tell me how to test if two strings can be found in another. ei:
String to test: "This is a great car you got"
Look for: "great" AND "car"
and what about upper case
String to test: "This is a great VOLVO you got"
Look for: "VOLVO" AND "car" (and not "volvo AND car")
Just don't get it
Thanks 5 1583
Kijak,
Does great need to precede car?
You can use Alternation to match two or more strings with a Regex, something
like:
Const pattern As String = "great|car"
Dim input As String = "The car is driven by a great dad"
Dim ex As New System.Text.RegularExpressions.Regex(pattern)
If ex.IsMatch(input) Then
Debug.WriteLine("Great Car Found!")
End If
A tutorial & reference on using regular expressions: http://www.regular-expressions.info/
The MSDN's documentation on regular expressions: http://msdn.microsoft.com/library/de...geElements.asp
Hope this helps
Jay
"Kijak" <ki*******@yahoo.dk> wrote in message
news:97*************************@posting.google.co m... Hi,
Im just starting working with REGEX and got a few problems. Could you tell me how to test if two strings can be found in another. ei:
String to test: "This is a great car you got" Look for: "great" AND "car"
and what about upper case
String to test: "This is a great VOLVO you got" Look for: "VOLVO" AND "car" (and not "volvo AND car")
Just don't get it
Thanks
Thanks, but I thought | was OR - mening it would match "The car is driven by
an ok dad" to?
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> skrev i en
meddelelse news:OI**************@TK2MSFTNGP12.phx.gbl... Kijak, Does great need to precede car?
You can use Alternation to match two or more strings with a Regex,
something like:
Const pattern As String = "great|car" Dim input As String = "The car is driven by a great dad" Dim ex As New System.Text.RegularExpressions.Regex(pattern) If ex.IsMatch(input) Then Debug.WriteLine("Great Car Found!") End If
A tutorial & reference on using regular expressions: http://www.regular-expressions.info/
The MSDN's documentation on regular expressions: http://msdn.microsoft.com/library/de...geElements.asp Hope this helps Jay "Kijak" <ki*******@yahoo.dk> wrote in message news:97*************************@posting.google.co m... Hi,
Im just starting working with REGEX and got a few problems. Could you tell me how to test if two strings can be found in another. ei:
String to test: "This is a great car you got" Look for: "great" AND "car"
and what about upper case
String to test: "This is a great VOLVO you got" Look for: "VOLVO" AND "car" (and not "volvo AND car")
Just don't get it
Thanks
Thanks, but I thought | was OR - mening it would match "The car is driven by
an ok dad" to?
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> skrev i en
meddelelse news:OI**************@TK2MSFTNGP12.phx.gbl... Kijak, Does great need to precede car?
You can use Alternation to match two or more strings with a Regex,
something like:
Const pattern As String = "great|car" Dim input As String = "The car is driven by a great dad" Dim ex As New System.Text.RegularExpressions.Regex(pattern) If ex.IsMatch(input) Then Debug.WriteLine("Great Car Found!") End If
A tutorial & reference on using regular expressions: http://www.regular-expressions.info/
The MSDN's documentation on regular expressions: http://msdn.microsoft.com/library/de...geElements.asp Hope this helps Jay "Kijak" <ki*******@yahoo.dk> wrote in message news:97*************************@posting.google.co m... Hi,
Im just starting working with REGEX and got a few problems. Could you tell me how to test if two strings can be found in another. ei:
String to test: "This is a great car you got" Look for: "great" AND "car"
and what about upper case
String to test: "This is a great VOLVO you got" Look for: "VOLVO" AND "car" (and not "volvo AND car")
Just don't get it
Thanks
Kijak,
Yes | is OR.
Yes it will match your string also. (my mistake).
Which is why I asked if "Does great need to precede car?", as you may need a
complex Alternation.
It also matters what can separate great from car (a space, any white space,
any character...).
In other words, which of the following strings match?
"great car"
"great fast car"
"great car"
"car great"
"car not so great"
"greater carrots"
"carrots are greater"
As I indicated in my original response. A tutorial & reference on using regular expressions: http://www.regular-expressions.info/
The MSDN's documentation on regular expressions: http://msdn.microsoft.com/library/de...geElements.asp
Are both valuable resources, especially the first one, to lean how to create
regular expressions!
Hope this helps
Jay
"kijak" <ki*******@yahoo.dk> wrote in message
news:u8**************@TK2MSFTNGP10.phx.gbl... Thanks, but I thought | was OR - mening it would match "The car is driven
by an ok dad" to?
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> skrev i en meddelelse news:OI**************@TK2MSFTNGP12.phx.gbl... Kijak, Does great need to precede car?
You can use Alternation to match two or more strings with a Regex, something like:
Const pattern As String = "great|car" Dim input As String = "The car is driven by a great dad" Dim ex As New System.Text.RegularExpressions.Regex(pattern) If ex.IsMatch(input) Then Debug.WriteLine("Great Car Found!") End If
A tutorial & reference on using regular expressions: http://www.regular-expressions.info/
The MSDN's documentation on regular expressions: http://msdn.microsoft.com/library/de...geElements.asp Hope this helps Jay "Kijak" <ki*******@yahoo.dk> wrote in message news:97*************************@posting.google.co m... Hi,
Im just starting working with REGEX and got a few problems. Could you tell me how to test if two strings can be found in another. ei:
String to test: "This is a great car you got" Look for: "great" AND "car"
and what about upper case
String to test: "This is a great VOLVO you got" Look for: "VOLVO" AND "car" (and not "volvo AND car")
Just don't get it
Thanks
Kijak,
Yes | is OR.
Yes it will match your string also. (my mistake).
Which is why I asked if "Does great need to precede car?", as you may need a
complex Alternation.
It also matters what can separate great from car (a space, any white space,
any character...).
In other words, which of the following strings match?
"great car"
"great fast car"
"great car"
"car great"
"car not so great"
"greater carrots"
"carrots are greater"
As I indicated in my original response. A tutorial & reference on using regular expressions: http://www.regular-expressions.info/
The MSDN's documentation on regular expressions: http://msdn.microsoft.com/library/de...geElements.asp
Are both valuable resources, especially the first one, to lean how to create
regular expressions!
Hope this helps
Jay
"kijak" <ki*******@yahoo.dk> wrote in message
news:u8**************@TK2MSFTNGP10.phx.gbl... Thanks, but I thought | was OR - mening it would match "The car is driven
by an ok dad" to?
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> skrev i en meddelelse news:OI**************@TK2MSFTNGP12.phx.gbl... Kijak, Does great need to precede car?
You can use Alternation to match two or more strings with a Regex, something like:
Const pattern As String = "great|car" Dim input As String = "The car is driven by a great dad" Dim ex As New System.Text.RegularExpressions.Regex(pattern) If ex.IsMatch(input) Then Debug.WriteLine("Great Car Found!") End If
A tutorial & reference on using regular expressions: http://www.regular-expressions.info/
The MSDN's documentation on regular expressions: http://msdn.microsoft.com/library/de...geElements.asp Hope this helps Jay "Kijak" <ki*******@yahoo.dk> wrote in message news:97*************************@posting.google.co m... Hi,
Im just starting working with REGEX and got a few problems. Could you tell me how to test if two strings can be found in another. ei:
String to test: "This is a great car you got" Look for: "great" AND "car"
and what about upper case
String to test: "This is a great VOLVO you got" Look for: "VOLVO" AND "car" (and not "volvo AND car")
Just don't get it
Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jon Maz |
last post by:
Hi All,
Am getting frustrated trying to port the following (pretty simple) function
to CSharp. The problem is that I'm lousy at Regular Expressions....
//from...
|
by: aevans1108 |
last post by:
expanding this message to microsoft.public.dotnet.xml
Greetings
Please direct me to the right group if this is an inappropriate place
to post this question. Thanks.
I want to format a...
|
by: bill tie |
last post by:
I'd appreciate it if you could advise.
1. How do I replace "\" (backslash) with anything?
2. Suppose I want to replace
(a) every occurrence of characters "a", "b", "c", "d" with "x",
(b)...
|
by: Dave |
last post by:
I'm struggling with something that should be fairly simple. I just don't
know the regext syntax very well, unfortunately.
I'd like to parse words out of what is basically a boolean search...
|
by: clintonG |
last post by:
I'm using an .aspx tool I found at but as nice as the interface is I
think I need to consider using others. Some can generate C# I understand.
Your preferences please...
<%= Clinton Gallagher
...
|
by: jg |
last post by:
I made a mistake somewhere in my vb code and I look, check and read against
the articles and help on regex, I still can't find the mistake I made.
I know my test string and the test patterns...
|
by: Talin |
last post by:
I've run in to this problem a couple of times. Say I have a piece of
text that I want to test against a large number of regular expressions,
where a different action is taken based on which regex...
|
by: Mark Chambers |
last post by:
Hi there,
I'm seeking opinions on the use of regular expression searching. Is there
general consensus on whether it's now a best practice to rely on this rather
than rolling your own (string)...
|
by: =?Utf-8?B?amFj?= |
last post by:
Hi,
I have problems with following code and don’t find the bug :
// Set
ArrayList aArray = new ArrayList();
regStr = new Regex(@"\?)*(\d+)\]");
if(text != null && regStr.IsMatch(text))...
|
by: jonnyboy6969 |
last post by:
Hi All
Really hoping someone can help me out here with my deficient regex skills :)
I have a function which takes a string of HTML and replaces a term (word or phrase) with a link. The pupose...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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: 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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |