I have a long text which contains paths to some files.
What I want to do is to remove the paths from it.
The filepaths are all something like:
some text 1
/all/extraItems/Java/.Scripts/.Sample1.js
some text 2
/all/extraItems/Android/.Scripts/.Sample2.js
some text 3
I know that using “^/all” will select a sentence that starts with /all and also .js$ for ending with .js. But I cannot merge these together to select the whole filepath.
After all the Regular Expression should be placed on the following code to remove the Paths.
text.replaceAll(<RegularExpression> , "");
Who can I write the regEx for it? Is there any tool?
If you want to “merge” them you will have to match the characters in between, as well:
.matches any character,*repeats the previous character 0 or more times,?makes the repetition ungreedy, avoiding a match going over multiple lines. Since you are using Java, you need to escape the backslash once more in your string:If you do not use the multiline option already (which you actually need to do, for
^/allandjs$to work on your input), you can do that like this: