开发者

What is the RegExpValidator.flags property used for?

I'm attempting to write a c开发者_如何学JAVAustom RegExpValidator in AS3 (similar to this). I'm wondering (and I've checked livedocs...), what is the 'flags' property on a RegExpValidator used for?

All of the examples I find set it to "g", what is that all about? The livedocs as well as some StackOverflow questions have the same use flags = "g".

What other values are allowed? What is the value-add of this property?


You can find a list of flags here:

  • g — When using the replace() method of the String class, specify this modifier to replace all matches, rather than only the first one. This modifier corresponds to the global property of the RegExp instance.
  • i — The regular expression is evaluated without case sensitivity. This modifier corresponds to the ignoreCase property of the RegExp instance.
  • s — The dot (.) character matches new-line characters. Note This modifier corresponds to the dotall property of the RegExp instance.
  • m — The caret (^) character and dollar sign ($) match before and after new-line characters. This modifier corresponds to the multiline property of the RegExp instance.
  • x — White space characters in the re string are ignored, so that you can write more readable constructors. This modifier corresponds to the extended property of the RegExp instance.


It means match globally. This is consistent with most regular expression engines. Otherwise it will only match the first case, so if your regex is to replace the word 'one' with 'two' without 'g', it only does the first match.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜