Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we match any single character including line feed in Perl regular expression?

I would like to use UltraEdit regular expression (perl) to replace the following text with some other text in a bunch of html files:

<style type="text/css">

#some-id{}

.some-class{}

//many other css styles follow

</style>

I tried to use <style type="text/css">.*</style> but of course it wouldn't match anything because the dot matches any character except line feed. I would like to match line feed as well and the line feed maybe either \r\n or \n.

How should the regular expression look like?

Many thanks to you all.

like image 466
bobo Avatar asked Dec 22 '22 03:12

bobo


1 Answers

Normally dot . matches all characters other than new line. Use the s modifier in the regex to force dot to match all characters including new line.

like image 128
Amarghosh Avatar answered Jan 12 '23 01:01

Amarghosh