String RegEx Multi Line
- 複数にまたがるストリングとマッチさせるには、/s が必要
- ストリングの定義==> https://developer.mozilla.org/en-US/docs/Web/CSS/string
- (?:\\\\'.$q.'|.)*? はescapeを考慮すると($qが'と仮定した場合)regex内では(?:\'|.)*?と解釈される。「\'」か「.」の文字が続くループであるが、*? であるのでLasy Matchである。つまり次に続く条件も見ている。もし次に続く条件があれば、ループをでる。
- (?>!\\\\)\\n はescapeを考慮するとregex内では(?>!\)\nと解釈される。意味は、「\ が前にこない \n」
/\'(?:\\'|.)*?(?:\'|(?>!\\)\n)/su
/\"(?:\\"|.)*?(?:\"|(?>!\\)\n)/su
content:"a\bc\\\\def";
=> true : "a\bc\\\\def"
content:"abc\"d'ef";
=> true : "abc\"d'ef"
content:'abc"d\'ef';
=> true : 'abc"d\'ef'
content:"abc\
def";
=> true : "abc\
def"
content:"ab\"c\
def";
=> true : "ab\"c\
def"