Hello i need a small help with regex.
I got this text, “#define TDD 0 // Values: 0 (FDD), 1(TDD)”
i used this regex : [#][d][e][f][i][n][e]\s.[T][D][D]\s.[\d]
but the result is : "#define TDD 0 // Values: 0 (FDD), 1" and i want “#define TDD 0” as output.
Am i on the right track ?
“A ‘#define’ instruction followed by a space followed by one or more uppercase characters (or underscores) followed by a space followed by one or more numbers”
I’ve guessed what you’re trying to capture, but more specific:
/#define TDD \n{1,}/
“’#define TDD ’ followed by one or more numbers”
Note I don’t now what flavour of regex you’re using, or what specifically you want too match, so this could be slightly off.
[] is for groups (one of…), so like [ABC] matches A, B or C, the way you’ve used it is redundant ([d] is one of “d”, which is exactly the same as d)