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

Nonbreaking space and GREP in UXP

Explorer ,
May 21, 2025 May 21, 2025

How to check if a character is a nonbreaking space in UXP?

if (chars[chars.indexOf(char) - 1].contents === " ") {
            console.log("yes");
          }

I can't use \u00A0 or /~S/. The first one doesn't work, the second can't be used in .jsx UXP.

TOPICS
UXP Scripting
203
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 , May 21, 2025 May 21, 2025
Translate
Explorer , May 22, 2025 May 22, 2025

Thank You for help.
Correct answer is

if (myCharacter.contents.toString() === "NONBREAKING_SPACE")
Translate
LEGEND , May 22, 2025 May 22, 2025
quote

Thank You for help.
Correct answer is

if (myCharacter.contents.toString() === "NONBREAKING_SPACE")

By @mateuszp13156491

 

You can save time on converting to string and just compare numeric value:

 

if (myCharacter.contents === 1397645907)
{
    alert("Non Breaking Space")
};

 

Translate
Community Expert ,
May 21, 2025 May 21, 2025

What about using 160 but the hex is \x{00A0} 

Also found this https://developer.adobe.com/indesign/dom/api/s/SpecialCharacters/#:~:text=NONBREAKING_SPACE%20%3D%20...

 

 

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
Explorer ,
May 22, 2025 May 22, 2025

Thank You for help.
Correct answer is

if (myCharacter.contents.toString() === "NONBREAKING_SPACE")
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
LEGEND ,
May 22, 2025 May 22, 2025
LATEST
quote

Thank You for help.
Correct answer is

if (myCharacter.contents.toString() === "NONBREAKING_SPACE")

By @mateuszp13156491

 

You can save time on converting to string and just compare numeric value:

 

if (myCharacter.contents === 1397645907)
{
    alert("Non Breaking Space")
};

 

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