Regex convert to title case on replace?


#1

I have hundred of these <figcaption>Large input</figcaption> that the boss wants to be title case.

In the past, I’ve done all upper and all lower on replace with switches in the expression.

First of all, does Atom support these, and can anyone tell me which to use for title case?


#2

It looks like Atom doesn’t support switches

find <figcaption>([A-Z])([A-Z]+)\b</figcaption>

replace <figcaption>$1\L$2</figcaption> on <figcaption>Normal</figcaption>

yields <figcaption>N\Lormal</figcaption>


#3
figcaption {
  text-transform: uppercase;
}

#4

Excellent Idea! More than one way to solve a problem, thanks

Of course it’s capitalize, not uppercase. But thanks.


#5
figcaption:first-letter {
  text-transform: uppercase;
}

:wink:

But in that case I would change it in the sources. As a rule of thumb, always have capitalized labels in the markup (for accessibility) and then only use CSS if you need to tweak the display (for upper/lower case).


#6

Can anyone advise which library I would need to petition (or contribute to) in order to have replacement text case conversion added for use in Atom.io?

It would be great to have full PCRE case conversion escape sequences available in Atom.io.

Text: Once again I say, "Hello World", and the world cries a little.

Search: (Hello) (World)
Replace: $U1 $L2

Result: Once again I say, "HELLO world", and the world cries a little.


#7

The find and replace capabilities in Atom are in the find-and-replace package. Because Atom doesn’t use PCRE for regular expressions though, it is highly unlikely that we will be taking something like this on.


#8

Hi Lee Dohm (@leedhom),

would using a package -

For instance be a good way to overcome this limitation? Do you have any experience with this?

Can you suggest any other packages that may fill this gap. Or, if not, how should one go about search and replace, in particular regex search and replace with Atom?


#9

Atom supports regular expressions for searching and replacing, just not the PCRE library to do it :grinning:

If you want to use the PCRE library for the above mentioned capabilities, then yes, a package would be the right way to go. I have lots of experience with building and maintaining packages but I’m not sure if that was what you were asking.


#10

HAHA, I was actually debating whether to add Perl integration to my package for the previewing feature. Guess it would be worth the effort after all!