I have the following problem:
- I want a regex to capture all characters in a paragraph that contains "#flashcard" and a string after a line break that starts with a "^" sign. E.g.,
lorem ipsum #flashcard ^4599993
- However, the regex should ignore/exlude the sign "^" itself. The result should be, e.g.,
lorem ipsum #flashcard 4599993
- I started with this regex
((?:[^\n][\n]?)+) #flashcard ?\n*((?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))+)
- I tried all kinds of modifications but it always captured the "^" sign. E.g.,
^(?!\^)(.*?)#flashcard:(.*?),(.*?),(.*?)(?:^.{1,3}$|^.{4}(?<!<!--).*)
.
Solution: A modification of this regex
((?:[^\n][\n]?)+) #flashcard ?\n*((?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))+)
that ignores the "^" sign.
Thank you for any help & advise!
This could be your pattern:
/^(.+?#flashcard )\^(.+?)$/
And then replace the matchings with:
$1$2