Page 1 of 1

How RegExp Rename only the first occurrence

Posted: 23 Feb 2022 00:51
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.

Re: How RegExp Rename only the first occurrence

Posted: 23 Feb 2022 07:25
by highend
VB6 doesn't support look behinds

^([^#]+)(#)(.+) > $1[$2$3

Re: How RegExp Rename only the first occurrence

Posted: 23 Feb 2022 08:47
by taufan
Great,
It's work.
Thank you highend.
🙏