+ 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.

19th Dec 2018, 9:20 PM
Rowsej
Rowsej - avatar
11 Antworten
+ 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/
19th Dec 2018, 11:43 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 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 :)
19th Dec 2018, 9:59 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 10
Danijel Ivanović it’s funny, because apart from me only mods have answered my question ;-)
20th Dec 2018, 12:25 AM
Rowsej
Rowsej - avatar
+ 8
Thanks for your help Anna! Sad that JS doesn’t support it 😢
19th Dec 2018, 9:52 PM
Rowsej
Rowsej - avatar
+ 7
Thanks for the info Kuba Siekierzyński!
19th Dec 2018, 10:05 PM
Rowsej
Rowsej - avatar
+ 7
Danijel Ivanović Thank you so much! You are my saviour!!
20th Dec 2018, 12:20 AM
Rowsej
Rowsej - avatar
+ 7
😄👍You are welcome friend! 🙌💪😆 I'm glad you found the solution! 🍻 I did not try to do that!
20th Dec 2018, 12:24 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 7
Danijel Ivanović Hacky, indeed... ;) Works in JS only, apparently. Python doesn't understand such syntax.
20th Dec 2018, 9:02 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
Kuba Siekierzyński 😀👍😉 Great, 😄🤓 I have to try! 🍻 Thank you! 💪😊
20th Dec 2018, 9:17 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 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
19th Dec 2018, 9:50 PM
Anna
Anna - avatar
+ 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)
19th Dec 2018, 11:13 PM
blackcat1111
blackcat1111 - avatar