Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> rx = /^(.*)$/mg
- >> tx = 'foonnbar'
- >> rx.exec(tx)
- [foo,foo]
- >> rx.lastIndex
- 3
- >> rx.exec(tx)
- [,]
- >> rx.lastIndex
- 4
- >> rx.exec(tx)
- [,]
- >> rx.lastIndex
- 4
- >> rx.exec(tx)
- [,]
- >> rx.lastIndex
- 4
- >> rx.lastIndex = 5
- 5
- >> rx.exec(tx)
- [bar,bar]
- >> rx.lastIndex
- 8
- >> rx.exec(tx)
- null
- /^(.*)((rn|r|n)|$)/gm
- /^(.*)[rn]*/gm
- var rx = /^/gm,
- tx = 'AnBnC',
- m;
- while(m = rx.exec(tx)){
- if(!m[0].length && rx.lastIndex > m.index){
- --rx.lastIndex;
- }
- foo();
- if(!m[0].length){
- ++rx.lastIndex;
- }
- }
- ^(.*)$
- ^(.+)$
- ^(.*)n? // remove all r characters beforehand
- ^(.*)(?:rn|nr|n|r)? // all possible CR/LF combinations, but *once* at most
Add Comment
Please, Sign In to add comment