"." Can match any single character, English letter, number, and itself. Now we can learn it by combining the full-text match described above:
Effect demonstration
The regular expression is as follows:
..g
Www.bkjia.com
Www.google.com
Www.abc.org
Www.bkjia.com
Www.google.com
Www.abc.org
As you can see, for the expression "www.bkjia.com", the "bkjia" section is a full-text match, and can only be fixed to match the "bkjia" string; ". ", can match any single character (including the character". ).
"." Can be used continuously. For example, we can write a regular expression like ". g. It will match all: text with any two characters in front, followed by a g, followed by any character.
This example code
<script type="text/javascript">function reg_replace(){var test = document.getElementById("test");regex = new RegExp("..g","g");test.innerHTML = test.innerHTML.replace(regex,"<span style='background-color:orange'>[.][.]g</span>");}function reg_split(){var test = document.getElementById("split");regex = new RegExp("..g","g");test.innerHTML = test.innerHTML.split(regex);}</script>
In many cases, "." does not match the line feed. Therefore, there is a noteworthy match: Carriage Return + exp, which is difficult to identify.
Additional reading
The topic list of this article is as follows:
- What is a regular expression?
- Getting started with regular expressions: match a Fixed Single Character
- Getting started with regular expressions: matching any single character
- Getting started with regular expressions: Use character groups
- Getting started with regular expressions: Use character ranges in character groups
- Getting started with regular expressions: Use of assense character groups
- Getting started with regular expressions: matching null characters
- Getting started with regular expressions: Match one or more characters
- Regular Expression: matches zero or multiple characters.
- Regular Expression entry: matches zero or one string.
- Getting started with regular expressions: Match fixed numbers of Characters
- Getting started with regular expressions: match the number of characters in a range
- Getting started with regular expressions: greedy matching
- Getting started with regular expressions: inert matching
- Entry to Regular Expressions: two matching Modes
- Getting started with regular expressions: match word boundaries
- Getting started with regular expressions: boundary definition and relativity
- Getting started with regular expressions: Match non-word boundaries
- Getting started with regular expressions: match the beginning and end of a text
- Entry to regular expression: submode
- Regular Expression entry: "or" Match
- Getting started with regular expressions: replacing with referenced text
- Getting started with regular expressions: unmatched
- Regular Expression Summary: Regular Expressions in JavaScript
- Regular Expression Summary: advanced application of regular expressions in js