Rename Rename

How to trim leading spaces?

[^-;]style=".*?" 

will choose it correctly, but includes a leading space. How to remove it?

 {{col.displ style="{cursor: col.cursor}" ng ayName}} // selection: ' style="{cursor: col.cursor}"' 
+4
source share
3 answers

Use a negative look:

 (?<![;-])style="[^"]*" 

The regular expression (?<![;-]) means that the previous character should not be ; or - ", but doesn’t write it: the traversal around is not captured, i.e. zero width.

+1
source

This includes everything that is NOT - or ; :

 [^-;] 

You want to cut spaces, you can add a space:

 [^-; ] 

To remove all space characters you can add:

 [^-;\s] 

Here is a good link for REGEX .

If you are only trying to capture a phrase starting with the word "style", then there is no reason for the match.

Then find something inside quotes that are not quotes:

 style=\"[^\"]+\" 

I added escape characters because I didn’t understand which application or language you included in this code.

0
source

try this template:

 style=["][^"]+["] 

or in your template you can do:

 [^-; ]style=["][^"]+["] 
-1
source

Source: https://habr.com/ru/post/1481510/


All Articles