正则表达式笔记(二)
转:http://www.regular-expressions.info/refadv.html
Regular Expression Advanced Syntax Reference?(?-s)Turn off "dot matches newline" for the remainder of the regular expression.?(?m)Caret and dollar match after and before newlines for the remainder of the regular expression. (Older regex flavors may apply this to the entire regex.)?(?-m)Caret and dollar only match at the start and end of the string for the remainder of the regular expression.?(?x)Turn on free-spacing mode to ignore whitespace between regex tokens, and allow # comments.?(?-x)Turn off free-spacing mode.?(?i-sm)Turns on the options "i" and "m", and turns off "s" for the remainder of the regular expression. (Older regex flavors may apply this to the entire regex.)?(?i-sm:regex)Matches the regex inside the span with the options "i" and "m" turned on, and "s" turned off.(a)?(?(1)b|c) matches ab, the first c and the second c in babxcacCommentsSyntaxDescriptionExample(?#comment)Everything between (?# and ) is ignored by the regex engine.a(?#foobar)b matches ab