Remove matched text

A swapping-ground for Regular Expression syntax

Remove matched text

Postby RenaMercer » Fri Sep 25, 2020 5:29 am

How do I match and remove the following?:

(Movie_2001) Something [group1]
(Movie_2019) Blah Blah (group2 release)
(Movie_2011) Insert title here {group 3}

Becomes:

Something [group1]
Blah Blah (group2 release)
Insert title here {group 3}

Thanks in advance!
RenaMercer
 
Posts: 5
Joined: Fri Sep 25, 2020 4:59 am

Re: Remove matched text

Postby Luuk » Fri Sep 25, 2020 9:21 am

Greetings. Sorry this is not regex, but Remove(5) may conduct likewise. In the crop its "Special", then in the right its "(*) ".
Luuk
 
Posts: 691
Joined: Fri Feb 21, 2020 10:58 pm

Re: Remove matched text

Postby therube » Fri Sep 25, 2020 5:48 pm

(Without looking [can't, I'm on XP]...)

With the new RegEx, if you enable that, thinking that:
Code: Select all
Match:  %1 %2
Replace:  %2

will work?
That would remove the first "word".
So, so long as "(something_something) " is consistent, thinking that should work.


Otherwise (with the "old") RegEx:
Code: Select all
Match:  ^\(.*?\s\)(.*)$
Replace:  \2

Match anything that starts with a paren, up the the closing paren<sp>, non-greedy, & ignore that, keeping all else.

---

Similar to Luuk's response...

5:Remove -> Crop -> Before (enter a space in the box)

Now that would remove the first "word" - rather then the first "word" surrounded by parenthesis.
So you must select the files you act on - carefully.
And so long as you do that, that could work.

If you're not careful, the first "word" - regardless of what it may be, will be removed.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Remove matched text

Postby RenaMercer » Fri Sep 25, 2020 7:03 pm

Thanks guys, it worked, I used the Remove(5).

I know a little bit of regex. At first I tested my regex on regex101.com which works but doesnt on the tool, but then I checked the "v2" option and it worked. Thanks again!
RenaMercer
 
Posts: 5
Joined: Fri Sep 25, 2020 4:59 am

Re: Remove matched text

Postby therube » Tue Sep 29, 2020 7:31 pm

but then I checked the "v2" option and it worked

That's got to be this:
Note that in v2 the unmatched text is copied to the output, unlike in the default regular expressions.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions