简体   繁体   中英

Regex match everything after parenthesis

I am trying to bulk rename around 10,000 files. I have a tool which can use Regex to do this.

I simply need a regex matching " (" and everything after that (space, parenthesis, everything).

Anyone able to help with this really simple problem real fast?

If you want the open parantheses included in the match:

/ \(.*/

If not, use a positive lookbehind:

/(?<= \().*/

See it in action here: http://regexr.com?32p42

You should really check out a tutorial , since this is probably the easiest thing you can do with regex. This should do:

[ ]\(.*

The square brackets are just to visualize the space. They can (but don't have to) be omitted.

Parentheses are meta-characters in regex, ie they mean something special. If you want to signify a literal character that happens to be a meta-character, you need to escape it using a backslash ( \\ ). For example, consider the caret ( ^ ), which is a meta-character that matches the beginning of a string.

^abcd
matches strings beginning with the sequence of characters "abcd"

\^abcd
matches the sequence of characters "^abcd"

You can read up on the difference between special and literal characters in regexen and how to escape them here: http://www.regular-expressions.info/characters.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM