To match "this" or "that" in string $str, I believe I would use this:
eregi("(this|that)", $str)
but what if I want to match "this" AND "that"?
I suppose I could use this:
eregi("this", $str) && eregi("that", $str)
But is there a better way? 6 3528
deko wrote: To match "this" or "that" in string $str, I believe I would use this:
eregi("(this|that)", $str)
but what if I want to match "this" AND "that"?
I suppose I could use this:
eregi("this", $str) && eregi("that", $str)
But is there a better way?
eregi("this.*that|that.*this", $str)
JW
> > eregi("this", $str) && eregi("that", $str) But is there a better way?
eregi("this.*that|that.*this", $str)
Is this saying: match the four letters "this" followed by a period, then
any combinbation of characters, then the four letters "that" (and vice
versa). What does the period do?
deko wrote: eregi("this", $str) && eregi("that", $str)
But is there a better way?
eregi("this.*that|that.*this", $str)
Is this saying: match the four letters "this" followed by a period, then any combinbation of characters, then the four letters "that" (and vice versa). What does the period do?
The period stands for 'any character'. So .* stands for: zero or more of
any character.
JP
--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
> >>>eregi("this", $str) && eregi("that", $str) But is there a better way?
eregi("this.*that|that.*this", $str)
Is this saying: match the four letters "this" followed by a period,
then any combinbation of characters, then the four letters "that" (and vice versa). What does the period do?
The period stands for 'any character'. So .* stands for: zero or more of any character.
I see. So, "this.*that" can be loosely understood to mean "match this and
that"?
deko wrote: I see. So, "this.*that" can be loosely understood to mean "match this and that"?
Yep: this anything-in-between-and that
JW
> > I see. So, "this.*that" can be loosely understood to mean "match this and that"?
Yep: this anything-in-between-and that
10-4. Thanks for the help! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Howard Dean |
last post by:
I have a string with several carriage returns in it. For example:
"This is
my test
string"
I wish to convert it to "This is my test string" (remove all carriage
returns. Can someone tell me...
|
by: K. Shier |
last post by:
my regex for matching phone #'s:
\({0,1}(?<areacode>{3})\){0,1}( |-){0,1}(?<prefix>{3})(
|-){0,1}(?<suffix>{4})
which i then .Replace to become:
(${areacode}) ${prefix}-${suffix}
question: ...
|
by: Q. John Chen |
last post by:
I have Vidation Controls
First One: Simple exluce certain special characters:
say no a or b or c in the string:
*
Second One:
I required date be entered in "MM/DD/YYYY" format:
//+4 How...
|
by: Larry Woods |
last post by:
I'm drawing a blank... What is the regular expression for search a string
for NO occurances of a substring? Example: I want to find all lines that
do NOT have the substing "image" in them.
...
|
by: Theadmin77 |
last post by:
Ok , i m playing with egrep command and i am a little stuck in these (i have researched google and MAN pages already ):
1.i need to search files using EGREP in the /var/log directory that contain...
|
by: bg_ie |
last post by:
I have the following Regex -
oldString = @"C:\ta";
Regex regexEndsInBackslash = new Regex(oldString + @"\\",
RegexOptions.Singleline | RegexOptions.IgnoreCase);
Any ideas why none of the...
|
by: MaxMax |
last post by:
I want to add a text to another text using regular expressions... An example
before= "foo"
after= "foobar"
before= "one"
after= "onebar"
before = ""
after = "bar"
|
by: SSJVEGETA |
last post by:
Hello, everybody. I have read some examples and manuals for the egrep command for Linux and I don't know if this egrep command is right for the particular files I am searching for. Here is what the...
|
by: Sin Jeong-hun |
last post by:
I'm trying to replace \n with @(representing the actual new line
character). Of course, \\n should not be replaced. What I'm trying to
do is simply what the good-old printf does.
For example, "\\n...
|
by: ndedhia1 |
last post by:
Right now, I am using this line of code to get rid of data in a file called alarmNotification that I do not want:
egrep "low debug.*\".*\"" $dbDir/alarmNotification.log
but I am having some...
|
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...
|
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: 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...
|
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:
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...
|
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: 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...
| |