Replace Space with Underscore Only Following Single Capitals

A swapping-ground for Regular Expression syntax

Replace Space with Underscore Only Following Single Capitals

Postby Wayne__Wickson » Fri Jan 05, 2024 3:57 pm

Replace Space with Underscore Only Following Single Capital Letters
(Even ChatGPT Can't Get This) :D
Given these four examples, I would like Bulk Rename Utility to replace the space following each single capital letter with an underscore while maintaining the rest of the string "as is".

2005_12_23 JACKSON A Leslie_'Les' 2005_12_28.jpg

2005_07_22 PICKELL(WALSH) Q Margaret_'Marg' 2005_07_25.jpg

2006_02_14 SHARPE(JONES) John_K 'Jack' 2006_02_19.jpg

2005_06_27 ALYEA F Delmar 2005_06_29.jpg

Wayne
Wayne__Wickson
 
Posts: 2
Joined: Wed Jan 03, 2024 3:21 pm

Replace "1Capital " with "1Capital_"

Postby Luuk » Mon Jan 08, 2024 6:02 am

Without example new-names, can use a checkmark for "v2" to replace any "space following each single capital letter"...
(?<=[_ ])([A-Z]) /g
$1_

2005_06_27 ALYEA F Delmar 2005_06_29 ----------------------------> 2005_06_27 ALYEA F_Delmar 2005_06_29
2005_07_22 PICKELL(WALSH) Q Margaret_'Marg' 2005_07_25 ----> 2005_07_22 PICKELL(WALSH) Q_Margaret_'Marg' 2005_07_25
2005_12_23 JACKSON A Leslie_'Les' 2005_12_28 -------------------> 2005_12_23 JACKSON A_Leslie_'Les' 2005_12_28
2006_02_14 SHARPE(JONES) John_K 'Jack' 2006_02_19 -----------> 2006_02_14 SHARPE(JONES) John_K_'Jack' 2006_02_19
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm


Return to Regular Expressions


cron