regular expression for multiple filenames

I have some files like that 15.58.55.ser 16.22.20.ser 16.36.23.ser 16.40.13.ser 16.59.41.ser 17.05.08.ser 17.14.40.ser 18.14.40.ser 18.20.43.ser I want to replace these filenames with the following format image_1.ser image_2.ser ....

I don't know how to achieve it.

please give me some advice.

Answers


The regex is quite simple:

(?:\d{2}\.){3}ser

It matches two digits \d{2} and a dot \. three times {3}, ending in ser.

You can see from RegExr that is matches all of your test cases.

However, in order to know how to do the replacement, you'd have to specify a language that you're working with.


Try this(If you need Java code)

String regex = "\\.ser";
fileName = "15.58.55.ser";
System.out.println(filename.replaceAll(fileName.split(regex)[0], "image_1"));

This is just for only one entry. If you want to replace multiple files, do it in For loop or whatever


Need Your Help

Validate register form

jquery-validate registration

I am trying make a register form adn using jquery validation. I have a problem.

Google Maps JS API v2 - jQuery number to word translation thingy

php jquery google-maps javascript

Ive got a problem, Im using jquery for my googlemaps thingy Im doin and Im gettin a number from an php array and I´m reading from it via a for-loop and want to translate that number into a word, for