Sublime text Find Replace any Character

special characterssublime-text-2sublime-text-3text-editors

Is there a way to find and replace using a special character that would allow any char to be in it's place?

What I mean by this is say I have the following text:

setI0100(mds3a1.getI0100().toString());
setI0200(mds3a1.getI0200().toString());
setI0300(mds3a1.getI0300().toString());
setI0400(mds3a1.getI0400().toString());
setI0500(mds3a1.getI0500().toString());
setI0600(mds3a1.getI0600().toString());
setI0700(mds3a1.getI0700().toString());
setI0800(mds3a1.getI0800().toString());
setI0900(mds3a1.getI0900().toString());
setI1100(mds3a1.getI1100().toString());
setI1200(mds3a1.getI1200().toString());
setI1300(mds3a1.getI1300().toString());

and I wanted to replace using something like (mds3a1.getI***().toString()); replacing the ending of all lines above after the initial (.

Where * could equal any character. Allowing me to replace the endings of all of the lines above even though they are not necessarily exactly all the same.
One line would look like:

Before:
    setI0100(mds3a1.getI0100().toString());
After:
    setI0100

I've seen similar functionality in other programs but I'm not exactly sure what the word for this behavior is.

EDIT:
Ended up I was looking for regular expressions as @DavidPostill pointed out below.

To do what I wanted I ended up with the following:

find: (\(mds3a1.getJ)....+(().toString\(\)\);)
replace: 

which would leave me with the text of each line up until and not including the first (

For anyone looking to use regex with sublime text here is a good resource I found. https://github.com/dmikalova/sublime-cheat-sheets/blob/master/cheat-sheets/Regular%20Expressions.cheatsheet

Best Answer

It appears that the MattDMo answer is not the correct pattern for the desired results. Here's what I did for a more elegant solution:

Open Sublime Text 2

Paste the block:

setI0100(mds3a1.getI0100().toString());
setI0200(mds3a1.getI0200().toString());
setI0300(mds3a1.getI0300().toString());
setI0400(mds3a1.getI0400().toString());
setI0500(mds3a1.getI0500().toString());
setI0600(mds3a1.getI0600().toString());
setI0700(mds3a1.getI0700().toString());
setI0800(mds3a1.getI0800().toString());
setI0900(mds3a1.getI0900().toString());
setI1100(mds3a1.getI1100().toString());
setI1200(mds3a1.getI1200().toString());
setI1300(mds3a1.getI1300().toString());

Find > Replace (CTRL+H)

Enable Regular expressions button (Alt+R)

Find What: \(.*

Replace With: [No characters here]

Press Replace All

Done

The result is what you were asking for:

Before:
    setI0100(mds3a1.getI0100().toString());
After:
    setI0100

Regex Breakdown:

\( Match and escape the ( character.

. Match any single character.

* Match preceding character 0 or more times.

Related Question