ਜਾਵਾਸਕ੍ਰਿਪਟ RegExp m ਮੁਦਦੀ
- ਪਿਛਲਾ ਪੰਨਾ d
- ਅਗਲਾ ਪੰਨਾ [abc]
- ਉੱਪਰ ਵਾਪਸ ਜਾਓ جاوا اسکریپت رگ ایکس مراجع手册
ਵਿਆਖਿਆ ਅਤੇ ਵਰਤੋਂ
m ਮੁਦਦੀ ਮਲਟੀ ਲਾਈਨ ਮੈਚ ਨੂੰ ਨਿਰਦੇਸ਼ ਦਿੰਦੀ ਹੈ。
It only affects the beginning. ^
and the end. $
behavior.
^
define the match item at the beginning of the string.
$
define the match item at the end of the string.
After setting "m",^
and $
also matches the beginning and end of each line.
Instance
Perform multiline search for "is" at the beginning of each line in the string:
let text = `Is this all there is` let pattern = /^is/m;
Hint 1
"m" modifier is case-sensitive rather than global.
To perform a global, case-insensitive search, use "m" with "g" and "i" together.
Example 1
Perform a global multiline search for "is" at the beginning of each string line:
let text = `Is this all there is` let pattern = /^is/gm;
Example 2
Perform a global, case-insensitive multiline search for "is" at the beginning of each string line:
let text = `Is this all there is` let pattern = /^is/gmi;
Example 3
Perform a global multiline search for "is" at the end of each string line:
let text = `Is this all there is` let text = "Is\nthis\nhis\n?"; let pattern = /is$/gm;
Hint 2
can be used multiline Property check if set m
ਮੋਡੀਫਾਇਰ
Check if the "m" modifier is set: let pattern = /W3S/gi; let result = pattern.multiline;
ਗਰਿੱਖਤ
new RegExp("regexp", "m")
ਜਾਂ ਘੱਟ ਤੋਂ ਘੱਟ ਲਿਖੋ:
/regexp/m
ਬਰਾਉਜ਼ਰ ਸਮਰਥਨ
/regexp/m
ਇਹ ECMAScript3 (ES3) ਵਿਸ਼ੇਸ਼ਤਾ ਹੈ。
ਸਾਰੇ ਬਰਾਉਜ਼ਰ ਐੱਸਈ3 (ਜਾਵਾਸਕ੍ਰਿਪਟ 1999) ਨੂੰ ਸਮਰਥਨ ਕਰਦੇ ਹਨ:
ਚਰਮੋਇਲ | ਆਈਈ | ਐਜ਼ | ਫਾਇਰਫਾਕਸ | ਸਫਾਰੀ | ਓਪਰਾ |
---|---|---|---|---|---|
ਸਮਰਥਨ | ਸਮਰਥਨ | ਸਮਰਥਨ | ਸਮਰਥਨ | ਸਮਰਥਨ | ਸਮਰਥਨ |
ਰੈਗੁਲਰ ਐਕਸਪ੍ਰੈਸ਼ਨ ਸਰਚ ਮੈਥਡਸ
ਜਾਵਾਸਕ੍ਰਿਪਟ ਵਿੱਚ, ਰੈਗੁਲਰ ਐਕਸਪ੍ਰੈਸ਼ਨ ਟੈਕਸਟ ਸਰਚ ਵੱਖ-ਵੱਖ ਤਰੀਕਿਆਂ ਨਾਲ ਪੂਰਾ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ。
ਵਰਤੋਂਪੈਟਰਨ (pattern)ਅਸਲ ਪੈਟਰਨ ਵਜੋਂ, ਇਹ ਸਭ ਤੋਂ ਮਹਤਵਪੂਰਨ ਮੈਥਡਸ ਹਨ:
ਉਦਾਹਰਣ | ਵਰਣਨ |
---|---|
text.match(ਪੈਟਰਨ) | ਸਟਰਿੰਗ ਮੈਥਡਸ match() |
text.search(ਪੈਟਰਨ) | ਸਟਰਿੰਗ ਮੈਥਡਸ search() |
ਪੈਟਰਨ.exec(text) | RexExp ਮੈਥਡਸ exec() |
ਪੈਟਰਨ.test(text) | RexExp ਮੈਥਡਸ test() |
- ਪਿਛਲਾ ਪੰਨਾ d
- ਅਗਲਾ ਪੰਨਾ [abc]
- ਉੱਪਰ ਵਾਪਸ ਜਾਓ جاوا اسکریپت رگ ایکس مراجع手册