I want to extract the last half-width alphanumeric characters in a regular expression.

Asked 2 years ago, Updated 2 years ago, 55 views

Questions about regular expressions.

■ Overview
"Well, after abc, it's def."

Please tell me the regular expression string to match the def of the above sentence.

■ Logic
***LOL I want to extract the "last" half-width alphanumeric characters that exist in *** of .

■ Current regular expression string
([0-9a-zA-Z!-~]+)(.*)(lol)

■ Match results for current regular expression string
Match string: after abc is def lol
Match string group 1: abc
Match string group 2: Next to def
Match String Group 3: LOL

■Contents of questions

one of the above groups has def Please tell me the regular expression string.
The point is "last".

regular-expression

2022-09-30 18:12

1 Answers

[0-9a-zA-Z!-~]+)(.*)(lol)

(.*) above is the negation of [0-9a-zA-Z!-~] ([^0-9a-zA-Z!-~]*) Why don't you change it to ?


2022-09-30 18:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.