Rectangle 27 3

You could do that with regular expressions but you'll eventually end up with ugly/complex/illegible expression. Instead use conjunction of simplier conditions joined togheter with logic operators:

if (strpos($filename, 'hello') !== 0 && strpos($filename, 'English') !== 0 && substr($filename, -4) === '.apk') {
    // filename matches
}

PHP's lack of standard string functions like contains() or starts|endsWith() makes above code a little bit ugly, but there's nothing that stopes you from creating a helper, utility class:

class StringHelper {
    private $subject;

    public function __construct($subject) {
        $this->subject = $subject;
    }

    public function contains($substring) {
        return strpos($this->subject, $substring) !== false;
    }

    public function endsWith($string) {
        return substr($this->subject, strlen($string) * -1) === $string;
    }
}

Then your if becomes even simpler:

$filename = new StringHelper($filename);

if ($filename->contains('hello') && $filename->contains('English') && $filename->endsWith('.apk')) {
    // matches
}

Hint: Instead of creating StringHelper object you could use a "classical" StringUtilis class with a bunch of static methods that accepts $string as their first argument.

Hint: StringHelper::contains() could accept an array of strings and check whether your string contains them all or at least one of them (depending on some sort of a flag given in second argument).

+1 This helps you now and helps with future problems.

This gives an error for the use of $this when not in object context??

Code of StringHelper did contain some errors I've fixed.

Thanks for you help, this worked a treat:-)

regular expression to match two different strings in PHP - Stack Overf...

php expression
Rectangle 27 16

If you really want to use a regular expression, try this:

(?=^(?:[^A-Z]*[A-Z]){2})(?=^(?:[^a-z]*[a-z]){2})(?=^(?:\D*\d){2})(?=^(?:\w*\W){2})^[A-Za-z\d\W]{8,}$
  • (?=^(?:[^A-Z]*[A-Z]){2}) tests for two repetitions of [^A-Z]*[A-Z] which is a sequence of zero or more characters except uppercase letters followed by one uppercase letter
(?=^(?:[^a-z]*[a-z]){2})
  • (?=^(?:\D*\d){2}) (same as above with digits)
  • (?=^(?:\w*\W){2}) (same as above with non-word characters, but you may change \W with a character class of whatever special characters you want)
  • ^[A-Za-z\d\W]{8,}$ tests the length of the whole string consisting only of character of the union of all other character classes.

Great answer with a nice explanation, I'm voting this up even though I don't recommend your answer. In this case I think it's becoming to unreadable, standard code would be a better choice, the only reason I would use regex because extreme performance was an issue and I needed to check millions of passwords.

Actually, if performance were a factor, it would be another reason not to use a regex. Otherwise I agree: +1 for the definitive regex solution (in case you really have to go that route).

+1 But instead of providing one long unreadable regex in native format (and a separate explanation), it is much better (and less work) to write the regex in free-spacing mode from the get-go, complete with proper indentation and generous comments. An additional benefit is that a verbose self-documenting free-spacing mode regex is much more maintainable in the future.

regex - PHP regular expression for strong password validation - Stack ...

php regex validation passwords
Rectangle 27 16

If you really want to use a regular expression, try this:

(?=^(?:[^A-Z]*[A-Z]){2})(?=^(?:[^a-z]*[a-z]){2})(?=^(?:\D*\d){2})(?=^(?:\w*\W){2})^[A-Za-z\d\W]{8,}$
  • (?=^(?:[^A-Z]*[A-Z]){2}) tests for two repetitions of [^A-Z]*[A-Z] which is a sequence of zero or more characters except uppercase letters followed by one uppercase letter
(?=^(?:[^a-z]*[a-z]){2})
  • (?=^(?:\D*\d){2}) (same as above with digits)
  • (?=^(?:\w*\W){2}) (same as above with non-word characters, but you may change \W with a character class of whatever special characters you want)
  • ^[A-Za-z\d\W]{8,}$ tests the length of the whole string consisting only of character of the union of all other character classes.

Great answer with a nice explanation, I'm voting this up even though I don't recommend your answer. In this case I think it's becoming to unreadable, standard code would be a better choice, the only reason I would use regex because extreme performance was an issue and I needed to check millions of passwords.

Actually, if performance were a factor, it would be another reason not to use a regex. Otherwise I agree: +1 for the definitive regex solution (in case you really have to go that route).

+1 But instead of providing one long unreadable regex in native format (and a separate explanation), it is much better (and less work) to write the regex in free-spacing mode from the get-go, complete with proper indentation and generous comments. An additional benefit is that a verbose self-documenting free-spacing mode regex is much more maintainable in the future.

regex - PHP regular expression for strong password validation - Stack ...

php regex validation passwords
Rectangle 27 16

Avoid regular expressions whenever you can, especially when processing xml. In this case you can use strip_tags() or simplexml, depending on your string.

regex - PHP regular expression to remove tags in HTML document - Stack...

php regex preg-replace html-parsing
Rectangle 27 39

function slug($z){
    $z = strtolower($z);
    $z = preg_replace('/[^a-z0-9 -]+/', '', $z);
    $z = str_replace(' ', '-', $z);
    return trim($z, '-');
}

great thanks.. Just one edit.. I want to remove dashes from beginning and end before returning $z just in case they exists.

(I see it does the translation shown in the example - but not what atif089 asked for)

@symcbean urlecode is not what I needed because I want to eliminate symbols rather than converting them. So this is exactly what I wanted.

@mario: 1. it doesn't do the same processing; 2. it's a maintenance nightmare.

regex - Regular Expression Sanitize (PHP) - Stack Overflow

php regex preg-replace sanitization
Rectangle 27 6

The problem with regular expressions is that they cannot match nested structures. Assuming your regex must match a single <div> and its closing tag, there is no way to correctly match this input:

<div id="a">
    <div id="b">
        Foo
    </div>
</div>
<div id="c">
    Bar
</div>

Because if your regular expression is greedy, it will match the two uppermost divs, and if it's ungreedy, it will not match the correct end tag.

Therefore, you should use an HTML parser. With PHP, DOMDocument::loadHTML or DOMDocument::loadHTMLFile each do a fairly good job. (You may "safely" ignore the warnings it generates: they're only markup errors, and the generated DOMDocument object should be pretty much okay.)

Since the PHP getElementById is a pain to get to work, you can use DOMXpath for the same purpose:

<?php

$url = "http://urlchecker.net/html/demo.html";

$d = new DOMDocument();
$d->loadHTMLFile($url);

$xpath = new DOMXPath($d);
$myNews = $xpath->query('//@id="news-id-160346"')->item(0);

?>

Hello I had try all answer but not successful Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: Unexpected end tag : a in urlchecker.net/html/demo.html, line: 26 in /home/urlcheck/public_html/html/test.php on line 10

@Thoman: it's actually been successful. loadHTMLFile simply tells you the problems it encountered while parsing. You can shut it up with the @ operator: @$d->loadHTMLFile($url);

I try it but this code don't matches all content in id='news-id-160346'

Php regular expression to match a div - Stack Overflow

php preg-match-all
Rectangle 27 610

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 610

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 609

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 609

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 598

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 595

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 595

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 594

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 594

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 594

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 594

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 594

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 594

The Stack Overflow Regular Expressions FAQ

*?
*+
+?
++
{n,m}
{n,}
{n}
[...]
[^...]
[^]
[\w-[\d]]
[a-z-[qz]]
[\w&&[^\d]]
[[:alpha:]]
[^\\D2]
[^[^0-9]2]
[^2[^0-9]]
\d
\D
\w
\W
\s
\S
\p{L}, \P{L}
\h
\t
\H
\V
\v
\e
\b
\B
\G
Matcher
(...)
(?:)
\1
$1
(?P<group_name>regexp)
(?>)
(?|)
(?P<groupname>regex)
(?<groupname>regex)
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
\K
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
  • Recursion (php and perl): (?R), (?0) and (?1), (?-1), (?&groupname)
java.util.regex.Matcher
matches()
  • find()): A match may be anywhere in the input string (substrings)
lookingAt()
  • The only java.lang.String functions that accept regular expressions: matches(s), replaceAll(s,s), replaceFirst(s,s), split(s), split(s,i)
preg_match
search
match
regexp
  • Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (blog post written by Stack Overflow's founder)*

Examples of regex that can cause regex engine to fail

  • Debuggex (Also has a repository of useful regexes) javascript, python, pcre
freeformatter.com
regex.larsolavtorvik.com

I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title Reference - What does this regex mean? does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..

@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.

@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.

@sln A rare example of when you should shoot the messenger.

Reference - What does this regex mean? - Stack Overflow

regex
Rectangle 27 3

Regular expressions is a poor tool for such task. You should really drop to a numerical comparison.

/^[6-9][0-9]$/

regex - Simple regular expression pattern for php - Stack Overflow

php regex