This link has been bookmarked by 179 people . It was first bookmarked on 17 Jun 2006, by craig hancock.
-
12 Mar 16
-
11 Mar 15
-
09 Jun 14
-
16 Nov 13
-
03 Apr 13
-
19 Dec 12
-
02 Oct 12
-
23 May 12
-
03 May 12
-
01 May 12
kevinmulletwritten within the context of perl, but is a good list of common practices for other venues as well, as long as they support the regex primitives used.
-
23 Apr 12
-
08 Feb 12
-
\w Match "word" character (alphanumeric plus "_")
-
\s Match whitespace character
-
-
13 Dec 11
-
18 Aug 11
-
06 Aug 11
-
26 May 11
-
04 May 11
-
28 Apr 11
-
10 Feb 11
-
11 Jan 11
-
20 Dec 10
-
15 Dec 10
-
01 Nov 10
-
Perl Regular Expressions
-
-
06 Aug 10
-
19 Jun 10
-
04 Jun 10
-
14 May 10
-
10 May 10
-
27 Apr 10
-
21 Apr 10
-
20 Apr 10
-
13 Apr 10
-
09 Apr 10
-
08 Apr 10
-
15 Mar 10
-
07 Mar 10
-
25 Oct 09
Andrew NoakesJust like =~, except negated. With matching, returns true if it DOESN'T match. I can't imagine what it would do in translates, etc.
-
22 Jul 09
-
01 Jul 09
-
25 Jun 09
-
10 Jun 09
-
14 May 09
-
17 Apr 09
-
31 Mar 09
-
19 Jan 09
-
13 Jan 09
-
29 Dec 08
-
26 Dec 08
-
29 Nov 08
-
22 Oct 08
-
13 Oct 08
-
20 Sep 08
-
04 Sep 08
-
19 Jul 08
-
08 Jul 08
-
The most basic string comparison is
$string =~ m/sought_text/;
The above returns true if string $string contains substring "sought_text", false otherwise. If you want only those strings where the sought text appears at the very beginning, you could write the following:$string =~ m/^sought_text/;
Similarly, the $ operator indicates "end of string". If you wanted to find out if the sought text was the very last text in the string, you could write this:$string =~ m/sought_text$/;
Now, if you want the comparison to be true only if $string contains the sought text and nothing but the sought text, simply do this:$string =~ m/^sought_text$/;
Now what if you want the comparison to be case insensitive? All you do is add the letter i after the ending delimiter:$string =~ m/^sought_text$/i;
-
-
26 May 08
Harjeet SinghSteve Litt's Perls of Wisdom:
Perl Regular Expressions
(With Snippets)-
- Introduction
- What They Are
- Doing String Comparisons
- Simple String Comparisons
- Using Simple "Wildcards" and "Repetitions"
- Using Groups () in Matching
- Using Character Classes []
- Matching: Putting it All Together
- Doing String Selections (parsing)
- Doing Substitutions
- Doing Translations
- Greedy and Ungreedy Matching
- Resolving Doubledots in A Filepath
- Kewl Splitpath One Liner Regex
- Using a Variable as a Match Expression:
- Symbol Explanations:
Perl Regular Expressions
(With Snippets)Copyright (C) 1998-2001 by Steve Litt
Recession got you down?
Contents
-
-
29 Apr 08
-
13 Feb 08
-
11 Feb 08
-
04 Feb 08
-
28 Jan 08
-
02 Jan 08
-
01 Jan 08
David RobertsRegular Expressions in Perl
perl regex reference programming regexp tutorial development
-
12 Dec 07
-
29 Nov 07
-
02 Oct 07
-
11 Sep 07
-
17 Jul 07
-
24 May 07
-
04 May 07
-
03 May 07
-
05 Apr 07
-
14 Mar 07
-
02 Mar 07
-
11 Jan 07
-
04 Dec 06
-
29 Nov 06
-
31 Oct 06
-
26 Sep 06
-
17 Sep 06
-
17 Aug 06
-
07 Aug 06
-
09 Jul 06
-
14 May 06
-
16 Apr 06
-
03 Apr 06
-
Steve Litt's PERLs of Wisdom: PERL Regular Expressions (With Snippets)
-
-
29 Mar 06
-
11 Oct 05
-
26 Aug 05
-
21 May 05
-
17 Apr 05
-
12 Apr 05
-
11 Feb 05
-
02 Feb 05
-
21 Jan 05
-
10 Jan 05
-
26 Aug 04
Page Comments
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.