![]() |
lower case to capital via regex
hi,
does anybody know, how i can change lower case to capital. (i mean whole words) via regex. :bulb2: |
coming closer
....while browsing through the regex references i found the search string:
([a-zA-Z])*- using the hyphen or any other (i.e. space) as the delimiter. BUT how to replace? please help! |
I'm pretty sure you cant batch replace with capitals.
Depending on how many need capitalizing, you've got two options. Loop through each lowercase letter and replace with it's capital Search 'a' -> Replace 'A' Search 'b' -> Replace 'B' etc. (match case) Or Copy all the text into a text editor of your choice, select a section that you want capitalized and in menus/toolbar 'Change to UPPERCASE'. (Will only work if your editor has that ability) Depending on how much you want changed and a couple of other factors, the Search/Replace will probably be easier, if not monotonous. |
css syntax has something called text-transform but I've not messed with it
http://www.w3schools.com/css/pr_text_text-transform.asp |
in general: is there a way to capitalize (+visversa) with regex?
thanks so far.
but i'm definitly searching for a REGEX solution. not just for SIGILs find/replace, also for other engines/progs with replace option. so, in general: is there a way to capitalize (+visversa) with regex? as i said: ([a-zA-Z])*- will find whole words ending with a choosen delimiter. i need the syntax for the replace field. |
Quote:
|
You can't replace with uppercased-match with regex.
|
I think the answer is is Python
I assume you guys are talking about the regex search and replace while doing a conversion.
I am hitting the same problem - except in my case I am matching on text which is in bold, and I want to make it upper case. If this Search/Replace is based on Python, why can't we use the Python function: string.upper() in my case it would be (\1).upper(), since \1 is the match group from my regex. Thanks, Goran |
A little over a year later but... with PCRE (that Sigil uses) anyway...
Find: \b(word)\b Replace with: \U\1\E Turns "word" into "WORD" Find: \b(word)\b Replace with: \u\1 Turns "word" into "Word" |
@DiapDealer Nice, but can you also change upper to lower case
e.g Chapter ONE -> Chapter One If it's lower to upper as wanted in topic we can do Chapter one -> Chapter One Search Code:
(Chapter )(.+?\b)Code:
\1\u\2Code:
Chapter ONECode:
Chapter OneEDIT: Found a solution. Search Code:
(Chapter )(.)(.+?\b)Code:
\1\u\2\L\3\E |
I see you already discovered a solution while I was typing, so I modified it so it will detect and fix Chapter TWENty-oNE as well. :D
Code:
(Chapter )(\w)(.+?\b)Code:
\1\u\2\L\3\ECode:
(Chapter )(\w)(.+?\b)((-)(\w)(.+?\b))?Code:
\1\u\2\L\3\E\5\u\6\L\7\E"Chapter ONe" will become "Chapter One" and "Chapter THIRTY-two" will become "Chapter Thirty-Two" :D |
Great, that also gives everyone a rough idea of how to adapt either version for other uses.
Thanks. |
Quote:
\u Uppercase the next character \l Lowercase next character \U Uppercase until \E \L Lowercase until \E \E End case modification |
| All times are GMT -4. The time now is 07:02 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.