+ 6

Help with Regular Expressions

I want to find this in strings: %RED% %BLUE% %JEKFJ% etc. I tryed with: /%+[a-zA-Z]+%/ /(%+[a-zA-Z]+%)/ /((%{1})+[a-zA-Z]+(%{1}))/ But it, or don't work, or select strings with more than one "%", for example "%%RED%"

7th Aug 2019, 6:08 PM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar
5 Antworten
+ 1
InvBoy [ :: FEDE :: ] you can see it in the code. If you need to match a string with exact start and end use the tokens for start =>"^" and end =>"
quot;. Hope it helps you 😉. https://code.sololearn.com/WS4mwwYKoy0x/?ref=app
7th Aug 2019, 7:17 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
Try (%[a-zA-z]+%), worked fine for me :)
8th Aug 2019, 9:50 AM
Fonie
Fonie - avatar
+ 2
/%[A-Z]+%/ will match all of these. If you want to exclude items with two %% for example, your need to tell the regex engine what to expect before the %. If you just don't want to allow %% at the beginning, then use this: /(?:[^%])%[A-Z]+%/
21st Aug 2019, 8:32 PM
Jonathan Cross
Jonathan Cross - avatar
+ 2
Don't listen to Cbr✔[ Most active ] That answer is wrong despite the upvotes!? Would only match 1 character between the % -- total nonsense.
21st Aug 2019, 8:45 PM
Jonathan Cross
Jonathan Cross - avatar
0
As you need to find specific words and characters that are known, I think you can use the following regex: \%(RED|BLUE|JEKFG)\% Here the code:https://code.sololearn.com/c6JlVeLwr05h/?ref=app
26th Sep 2019, 2:31 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar