Add (7) Word Space - Exclude Non-Alphanumeric Characters

Would you like Bulk Rename Utility to offer new functionality? Post your comments here!

Re: Add (7) Word Space - Exclude Non-Alphanumeric Characters

Postby Admin » Tue Apr 29, 2025 2:11 am

In most modern regex flavors (PCRE, JavaScript, Python’s re, etc.), the special token \b (word boundary) matches the position between a “word” character (\w) and a “non-word” character (\W), or the start/end of the string. By definition:

Word characters (\w) are:
Upper- and lower-case letters (A–Z, a–z)
Digits (0–9)
The underscore (_)

Non-word characters (\W) are everything else (spaces, punctuation, symbols, etc.), including the hyphen (-).
Admin
Site Admin
 
Posts: 2889
Joined: Tue Mar 08, 2005 8:39 pm

Re: Add (7) Word Space - Exclude Non-Alphanumeric Characters

Postby spacev2 » Tue Apr 29, 2025 2:48 am

That's correct, if you were to implement the 2 feature requests those file name examples would not be changed.

However, there are also scenarios where it would be desirable to have the option to insert spaces between strings of consecutive capital letters and between capital letters that reside next to non-alpha numeric characters. So it would be nice to have those options also.
spacev2
 
Posts: 55
Joined: Fri Dec 22, 2023 10:58 pm

Re: Add (7) Word Space - Exclude Non-Alphanumeric Characters

Postby Admin » Tue Apr 29, 2025 3:12 am

insert spaces between strings of consecutive capital letters


Regex
Match: (?<=[A-Z])(?=[A-Z])/g
Replace: <sp>

<sp> = space

insert spaces before capital letter


Regex
Match: (?<!^)(?=[A-Z])/g
Replace: <sp>

<sp> = space

-----------------------------------

I think adding a Word Space with Add (7) should just result in:

"MyHolidayTomorrow" -> "My Holiday Tomorrow"
"My_Holiday_Tomorrow" remains unchanged
"My-Holiday-Tomorrow" remains unchanged
[PREFIX] remains unchanged

This matches better the "Word Space" functionality as you mentioned.
Admin
Site Admin
 
Posts: 2889
Joined: Tue Mar 08, 2005 8:39 pm

Re: Add (7) Word Space - Exclude Non-Alphanumeric Characters

Postby spacev2 » Tue Apr 29, 2025 7:34 am

Maybe implementing a new independent "Spacing" rule could be a good idea ?
spacev2
 
Posts: 55
Joined: Fri Dec 22, 2023 10:58 pm

Re: Add (7) Word Space - Exclude Non-Alphanumeric Characters

Postby spacev2 » Tue Apr 29, 2025 10:25 am

Conceptual idea for a independent "Word Spacing" rule in BRU.

Image
spacev2
 
Posts: 55
Joined: Fri Dec 22, 2023 10:58 pm

Re: Add (7) Word Space - Exclude Non-Alphanumeric Characters

Postby spacev2 » Tue Apr 29, 2025 8:08 pm

Conceptual idea for a independent "Word Spacing" rule in BRU.

Image
spacev2
 
Posts: 55
Joined: Fri Dec 22, 2023 10:58 pm

Previous

Return to Suggestions