Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Find and Replace using Regex - change $1 Result to uppercase?

New Here ,
Mar 10, 2022 Mar 10, 2022

Hi,

I am doing a regex search:

//\s+([a-zA-Z])

To find all lines that  match this:

 

// test

// another test

...

I would like to change the first char to uppercase. I thought I could  use the following in the replace:

// \U$1

to instruct the $1 result to be upper case but this doesn't work in dreamweaver.

Is there a way of instructing the search and replace dialogue to alter the $ output?

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2022 Mar 10, 2022

I don't follow.  Can you be more specific?  Give us some examples of the target string you're searching for and what should replace it.

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2022 Mar 10, 2022

Indeed, the 

\U$1

instruction does not work in DW but as expected in Notepad++.

 

However (unless you want it to), the initial request you make includes the invisible characters before any first letter, which results in the removal of that character when replacing.

In addition, this query also includes characters that are already capitalized, which is not necessary in itself.

 

So, I would suggest replacing your query with

(\b[a-z](?!\s))

And

\U$1

 If I find an alternative in DW, I will come back to this post, but often, I make the REGEX in Notepad++, even in Vim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2022 Mar 10, 2022
quote

// test

// another test

...

By @RigidCollision

Youps, sorry, when I saw my answer displayed, I understood that, in your question,  the lines starting with / corresponded to your search fields, so, your initial query and your replacement expression are quite correct.

They should work, if not, DW acts as expected, switch to Notepad++.
Sorry again for the noise.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2022 Mar 10, 2022
LATEST

*DW doesn't act as expected

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines