View previous topic :: View next topic |
Author |
Message |
echonine
Joined: 03 Feb 2008 Posts: 4
|
Posted: Tue Jun 17, 2008 5:42 pm Post subject: Replace first character |
|
|
Please tell me what is wrong with this:
(?Ex) [\-]+ # replace first '_' character with '_-_' in prefix
I'm trying to replace only the first occurrence of the underline character in the file name, but not any subsequent occurrences in that file name, with the three characters shown above.
Thanks in advance for your help  |
|
Back to top |
|
 |
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed Jun 18, 2008 4:10 am Post subject: |
|
|
I'm assuming you want to replace underline characters as you stated and not the dash character as you have specified in the regex.
There are 2 ways to do this:
1)
This method uses the PFrank extension where you put a number in the flags ie. use (?E1x) instead of (?Ex)
The number specifies the number of replacements you'd like to make. In this case it is 1.
Row: 1
Search: '(?E1x) [_]+ # replace first '_' character with '_-_' in prefix'
Replace: '_-_'
or
You can do the following where you isolate the first dash.
Row: 1
Search: '(?Ex)^(.*?)[_]+(.*)$ # replace first '_' character with '_-_' in prefix'
Replace: '\1_-_\2'
Hope this helps!
Peter. |
|
Back to top |
|
 |
echonine
Joined: 03 Feb 2008 Posts: 4
|
Posted: Wed Jun 18, 2008 4:02 pm Post subject: |
|
|
That works perfectly. Thank you so much for your help.
Your's is one terrific program! It is so kind of you to provide it to us. |
|
Back to top |
|
 |
|