How RegExp Rename only the first occurrence

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
taufan
Posts: 53
Joined: 22 Mar 2020 02:33

How RegExp Rename only the first occurrence

Post by taufan »

Hi,

How RegExp Rename and Replace only the first occurrence?

Example:

Picnic - 1 #cv2 #kid #fff.jpg
Picnic - 2 #kid #cv #fff.jpg
Picnic X - 3 #fff #cv1.jpg

Expected results:

Picnic - 1 [#cv2 #kid #fff.jpg
Picnic - 2 [#kid #cv #fff.jpg
Picnic X - 3 [#fff #cv1.jpg


I try RegExp Rename this code but didn't work:

(?<!#.*)# > [#


If successful, then the next final step is to make the filename like this:

Picnic - 1 [#cv2 #kid #fff].jpg

Any idea?
I just try to dive into the world of Regex.

Thanks for your help.
I really appreciated it.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How RegExp Rename only the first occurrence

Post by highend »

VB6 doesn't support look behinds

^([^#]+)(#)(.+) > $1[$2$3
One of my scripts helped you out? Please donate via Paypal

taufan
Posts: 53
Joined: 22 Mar 2020 02:33

Re: How RegExp Rename only the first occurrence

Post by taufan »

Great,
It's work.
Thank you highend.
🙏

Post Reply