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

regex find any neumeric value not contained in double quotes

Community Beginner ,
Oct 30, 2024 Oct 30, 2024

10/30/2024

What is the correct regex syntax to find a numeric value not in double quotes?

Thanks for the help.

Carl

TOPICS
Code , How to
779
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

correct answers 3 Correct answers

Community Expert , Oct 30, 2024 Oct 30, 2024

To find numeric values not enclosed in double quotes, you can use a negative lookbehind and lookahead assertion in your regex pattern. Here's an example:

(?<!")\b\d+\b(?!")

Explanation:

  • (?<!") is a negative lookbehind assertion that ensures the numeric value is not preceded by a double quote.

  • \b\d+\b matches a numeric value. \b is a word boundary to ensure it's a standalone number, and \d+ matches one or more digits.

  • (?!") is a negative lookahead assertion that ensures the numeric v

...
Translate
Community Expert , Oct 30, 2024 Oct 30, 2024

Search for

(?<!")\b\d+\b(?!")

 

Replace with

"$1"

 

Explanation:

"$1" - This replacement pattern uses $1, which refers to the first capturing group (the numeric value). By enclosing it in double quotes, we ensure the numeric value gets wrapped in quotes.

 

Translate
Community Expert , Oct 31, 2024 Oct 31, 2024

Your old HTML code should be modernized to current HTML5 & CSS web standards.

 

Example:

https://www.w3schools.com/css/tryit.asp?filename=trycss_table_vertical-align

 

Code Validation Services:

HTML: https://validator.w3.org/

CSS: https://jigsaw.w3.org/css-validator/

 

Translate
Community Expert ,
Oct 30, 2024 Oct 30, 2024

To find numeric values not enclosed in double quotes, you can use a negative lookbehind and lookahead assertion in your regex pattern. Here's an example:

(?<!")\b\d+\b(?!")

Explanation:

  • (?<!") is a negative lookbehind assertion that ensures the numeric value is not preceded by a double quote.

  • \b\d+\b matches a numeric value. \b is a word boundary to ensure it's a standalone number, and \d+ matches one or more digits.

  • (?!") is a negative lookahead assertion that ensures the numeric value is not followed by a double quote.

 

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
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 Beginner ,
Oct 30, 2024 Oct 30, 2024

Thanks for your time and help. the expression worked well. Your explanation was detailed and great. 

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 Beginner ,
Oct 30, 2024 Oct 30, 2024

What I was trying to do is update some old html code.  For example <td valign="TOP" height=20>     in dreamweaver gives me the warning of "the value of attribute height must be contained in double quotes"   1. So I find all numeric values not contained in double quotes.

2.  Then add the double quotes to the numeric value or attribute .   example   <td valign="TOP" height="20">  the value of 20 is contained in double quotes.   

What is the correct replace with syntax ?  the numeric value could be anything. so some type of wild card ?  double quotes, asterix for the wildcard,  double quotes  "*"?    Am I going about this wrong ? Maybe there is a simpler way.   Thanks 

 

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 ,
Oct 30, 2024 Oct 30, 2024

Search for

(?<!")\b\d+\b(?!")

 

Replace with

"$1"

 

Explanation:

"$1" - This replacement pattern uses $1, which refers to the first capturing group (the numeric value). By enclosing it in double quotes, we ensure the numeric value gets wrapped in quotes.

 

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
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 Beginner ,
Oct 31, 2024 Oct 31, 2024
LATEST

Thanks again for the help.

Maybe someone can help with this error.  I am using Adobe Dreamweaver 19.2.1.    

I receive the following error when executing  my find and replace string  and selecting replace allRegular expression syntax error:  invalid quantifier.  

Search string  =(?<!")\b(\d+)\b(?!")

Replace string  ="$1"

I do not recieve the error if I simply select replace. Adobe makes the appropriate changes with no error. The error  only occurs if I click replace all.

Thanks

 

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 ,
Oct 31, 2024 Oct 31, 2024

Your old HTML code should be modernized to current HTML5 & CSS web standards.

 

Example:

https://www.w3schools.com/css/tryit.asp?filename=trycss_table_vertical-align

 

Code Validation Services:

HTML: https://validator.w3.org/

CSS: https://jigsaw.w3.org/css-validator/

 

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