+ 3
Match a string which is succeeded by a character but don't match the character itself in regex
I have a string "a_c d_" I want to just be able to match the letters using regex that are immediately succeeded by `_`. For example, "a" & "d". I tried using the pattern `\w_`, but it matches the letter as well as the underscore. So the returned values are "a_" & "d_". But I just want to have "a" & "d". How can I do that?
3 RĂ©ponses
+ 5
XXX , lookahead pattern is what you need. Look at the code. Hope it helps you.
https://code.sololearn.com/WaeK72RAIoRu/?ref=app
+ 2
đđąđąđđš đđĄđđČđđ„ quoted from the question
`I tried using the pattern '\w_', but it matches the letter as well as the underscore. So the returned values are "a_" & "d_"`
I know the guidelines.
EDIT: made the question clearer by separating into paragraphs