Copy link to clipboard
Copied
10/30/2024
What is the correct regex syntax to find a numeric value not in double quotes?
Thanks for the help.
Carl
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
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.
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/
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks for your time and help. the expression worked well. Your explanation was detailed and great.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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 all. Regular 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
Copy link to clipboard
Copied
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/