0

I want to find(to remove this with perl, but this is not the question) all characters, digits, whitespaces before a special regex.

Example:

this is my test
foo ... == < foo
something else

myregex
 all other

So I want to find

this is my test
foo ... == < foo
something else

its ok when

myregex

is also "highlighted".

I found some other post regex to remove all text before a character, but this does not realy match my problem...

Community
  • 1
  • 1
alabamajack
  • 642
  • 8
  • 23

1 Answers1

-1

The question is worded very badly. As I understand it, you want to remove everything before the part that matches your regular expression.

If that's the case, this might help: s/.*(<REGEX>)/\1/g
This matches all the characters before your regex (.*) and then matches your regex and creates a group. Once the matching is complete, it replaces all the matched section with the contents of the group alone (\1).

YMI
  • 165
  • 1
  • 10