+ 13
Is there any RegEx metacharacter that will match anything, including line breaks?
The dot/period matches any character except line breaks. Is there any metacharacter that will match anything, including line breaks? Thank you in advance.
11 odpowiedzi
+ 14
The Dot Matches (Almost) Any Character
https://www.regular-expressions.info/dot.html
Rowsej Check out ThisOne! ;)
Match any character including new line in Javascript Regexp
https://loune.net/2011/02/match-any-character-including-new-line-in-javascript-regexp/
+ 10
I don't know if it will work for JS, but for Python you can use sth like (\n|.)+ to find any character (either "dot" any or a newline explicitly) -- it should return exactly one match - the whole text :)
+ 10
Danijel Ivanović it’s funny, because apart from me only mods have answered my question ;-)
+ 8
Thanks for your help Anna! Sad that JS doesn’t support it 😢
+ 7
Thanks for the info Kuba Siekierzyński!
+ 7
Danijel Ivanović Thank you so much! You are my saviour!!
+ 7
😄👍You are welcome friend! 🙌💪😆
I'm glad you found the solution! 🍻
I did not try to do that!
+ 7
Danijel Ivanović Hacky, indeed... ;) Works in JS only, apparently. Python doesn't understand such syntax.
+ 7
Kuba Siekierzyński 😀👍😉
Great, 😄🤓 I have to try! 🍻
Thank you! 💪😊
+ 6
Usually you can make the dot match any character including line breaks if you combine it with a meta command like S() or DOTALL. Unfortunately, this site says that this doesn't work in Javascript: https://regular-expressions.mobi/javascript.html
+ 6
This probably won't work since I haven't tried it, but if you match a character with an "anti-character" like
([\S\s])
It'll probably match anything.
(But like I said I'm not very confident)