Editing
Regular expression
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Quick Reference Table == Note: (1) Blue highlighted areas in samples represent text matching the rules, (2) The same text rule can have multiple representations {| class="wikitable" |- ! Text Rule ! Sample ! Opposite Text Rule ! Sample |- | Any single character (including spaces, but not newline) <br> <code>.</code> | <span style="background:#C6E3FF">W</span>hat Does the Fox Say? 12 狐狸怎叫 34 | | |- | Any character (including spaces), appears 1 or 0 times <br> <code>.?</code> = <code>.{0,1}</code> | <span style="background:#C6E3FF">W</span>hat Does the Fox Say? 12 狐狸怎叫 34 | | |- | Any number of multiple characters (including spaces) <br> <code>.*</code> = <code>.{0,}</code> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span> | | |- | Any number of characters (including spaces), at least 1 occurrence <br> <code>.+</code> = <code>.{1,}</code> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span> | | |- | Any number of spaces or newlines (at least 1 occurrence) <br> <code>\s+</code> | What<span style="background:#C6E3FF"> </span>Does the Fox Say? 12 狐狸怎叫 34 | Any number of characters (not including spaces or newlines) <br> <code>[^\s]+</code> = <code>[^\s]{1,}</code> = <code>[\S]+</code> = <code>[^ ]+</code> | <span style="background:#C6E3FF">What</span> Does the Fox Say? 12 狐狸怎叫 34 |- | Any number of ASCII characters (including English, numbers and spaces) <br> <code>[\x00-\x80]+</code> or <code>[[:ascii:]]+</code> | <span style="background:#C6E3FF">What Does the Fox Say? 12</span> 狐狸怎叫 34 | Non-ASCII, i.e., Chinese characters appearing any number of times <br> <code>[^\x00-\x80]+</code> | What Does the Fox Say? 12 <span style="background:#C6E3FF">狐狸怎叫</span> 34 |- | Any number of uppercase/lowercase English letters, numbers and underscore (_) (not including spaces) <br> <code>[\w]+</code> = <code>[a-zA-Z0-9_]+</code> <br> PHP with <code>u</code> modifier supports Chinese characters | <span style="background:#C6E3FF">What</span> <span style="background:#C6E3FF">Does</span> <span style="background:#C6E3FF">the</span> <span style="background:#C6E3FF">Fox</span> <span style="background:#C6E3FF">Say</span>? <span style="background:#C6E3FF">12</span> 狐狸怎叫 <span style="background:#C6E3FF">_34</span> | Any number of characters that are not English letters, numbers and underscore (_) <br> <code>\W+</code> = <code>[^a-zA-Z0-9_]+</code> | |- | Any number of digits (not including spaces) <br> <code>[\d]+</code> = <code>[0-9]+</code> | What Does the Fox Say? <span style="background:#C6E3FF">12</span> 狐狸怎叫 34 | Any number of characters not including digits (including spaces) <br> <code>[^\d]+</code> = <code>[^0-9]+</code> = <code>\D+</code> | <span style="background:#C6E3FF">What Does the Fox Say? </span>12 狐狸怎叫 34 |- | Any number of Chinese characters <br> <code>[\p{Han}]+</code> | What Does the Fox Say? 12 <span style="background:#C6E3FF">狐狸怎叫</span> 34 | Any number of characters not including Chinese <br> <code>[^\p{Han}]+</code> | |- | Lines starting with “狐狸” <br> <code>^狐狸.*$</code> | <span style="background:#C6E3FF">狐狸怎叫 34 What Does the Fox Say?</span><br>柴犬怎叫 What Does the shiba inu say? | Lines not starting with “狐狸” <br> <code>^(?!狐狸).*$</code> | 狐狸怎叫 34 What Does the Fox Say?<br><span style="background:#C6E3FF">柴犬怎叫 What Does the shiba inu say?</span> |- | Lines ending with “怎叫” <br> <code>^.*怎叫$</code> | What Does the Fox Say? 12 狐狸怎叫 34<br><span style="background:#C6E3FF">What Does the shiba inu say? 柴犬怎叫</span> | Lines not ending with “怎叫” <br> <code>.*(?<!怎叫)$</code> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span><br>What Does the shiba inu say? 柴犬怎叫 |- | Lines containing “狐狸” <br> <code>^.*狐狸.*$</code> or <code>(狐狸)</code> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span><br>What Does the shiba inu say? 柴犬怎叫 | Lines not containing “狐狸” <br> <code>^((?!狐狸).)*$</code> | What Does the Fox Say? 12 狐狸怎叫 34<br><span style="background:#C6E3FF">What Does the shiba inu say? 柴犬怎叫</span> |- | Boolean logic AND: Lines containing both “狐狸” and “叫” <br> <code>(?=.*狐狸)(?=.*叫).*</code> or <code>狐狸.*叫\|叫.*狐狸</code> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span><br><span style="background:#C6E3FF">What Does the Fox Say? 12 不叫狐狸 34</span><br>What Does the shiba inu say? 柴犬怎叫 | | |- | Boolean logic OR: Lines containing “狐狸” or “叫” <br> <code>.*(狐狸\|叫).*</code> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34<br>What Does the shiba inu say? 柴犬怎叫</span><br>What Does the shiba inu say? 柴犬怎了 | Boolean logic: Lines not containing “狐狸” and not containing “柴犬” <br> <code>^((?!狐狸\|柴犬).)*$</code> | What Does the Fox Say? 12 狐狸怎叫 34<br>What Does the shiba inu say? 柴犬怎叫<br><span style="background:#C6E3FF">What Does the Husky say? 哈士奇怎叫</span> |- | Boolean logic NOT: Lines not containing “狐狸” but containing “柴犬” <br> <code>^((?!狐狸).)*(柴犬).*$</code> = <code>^(柴犬).*((?!狐狸).)*$</code> = <code>(柴犬).*((?!狐狸).)*</code> | What Does the Fox Say? 12 狐狸怎叫 34<br><span style="background:#C6E3FF">What Does the shiba inu say? 柴犬怎叫</span> | | |}
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information