Reputation: 86925
I'd like to match all digits that are in front of the character K
and extract that value.
In the example CARRY18K
it would match the 18
.
Probably I can only achive this with regex, but how?
Is \d+K
the right expression here?
Upvotes: 1
Views: 63
Reputation: 786289
I'd like to match all digits that are in front of the character K and extract that value.
You should use:
\d+(?=K)
(?=K)
is positive lookahead that makes sure that digits are followed by K
Upvotes: 2
Reputation: 91518
I'd use something like this:
\d+K
If you want to capture the digits:
(\d+)K
Upvotes: 2