i need help for regex.
I have a string :
1°) Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Lorem Ipsum is simply dummy text of the printing and typesetting :
2°)Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Of this string i want 2 matches 1°) string following
and 2°) string following
I tried with (?<\d°\)).*
but this regex does not match the enter key.
Thanks for any help.
CodePudding user response:
You can use
(?m)^\d °\).*(?:\n(?!\d °\)).*)*
See the regex demo. Details:
(?m)
- a MULTILINE option^
- start of a line\d
- one or more digits°\)
- a°)
fixed string.*
- the rest of the line(?:\n(?!\d °\)).*)*
- zero or more lines that are not starting with one or more digits and°)
A splitting approach would involve a pattern like
(?:\r\n?|\n)(?=\d °\))
See the regex demo. Details:
(?:\r\n?|\n)
- a line break sequence(?=\d °\))
- a positive lookahead that requires one or more digits and then°)
immediately to the right of the current location.