I need to remove periods (.) from filenames, UNLESS it is the period for the extension.
For example if something was named 1.1.2.3.jpg I would need it to be named 1123.jpg.
I can't think of any logic for this =/ perhaps because my regex knowledge is not too great.
need help with removing periods [SOLVED]
Moderator: General Moderators
need help with removing periods [SOLVED]
Last edited by s.dot on Thu Nov 10, 2005 4:01 pm, edited 1 time in total.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
[feyd@work]>php -r "$a = '1.1.2.3.jpg'; function stripP($a) { array_shift($a); $a[0] = str_replace('.','',$a[0]); return implode('',$a); } echo preg_replace_callback('#^(.*?)(\.[^\.]+?)?$#','stripP',$a);"
1123.jpgthat, my friend, is the epitome of awesomeness.
Thanks
Thanks
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.