2

I have the input and regex of

  const input = `iPhone Xʀ`;
  
  console.log(input.match(/^([\w\d\-\s]*)/));

I have not been able to figure out how to match the ʀ unicode character.

I tried \\p{L} as noted in another SO post. Also tried putting u for unicode as a modifier.

2 Answers 2

2

Use \p{L} in conjunction with the flags gu:

const input = `iPhone Xʀ`;
console.log(input.match(/^([\w\d\-\s]*\p{L})/gu));
  
// output:

// [
//  "iPhone Xʀ"
// ]

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer. not using the g flag also worked
@RayJ_inSJ Happy to help. Regarding the g flag, if it's omitted, the resulting array has two entries, with it only one. Not sure if that makes a difference in your case but worth pointing out.
0

Please get the Unicode of the character and use the following pattern.

  const input = `iPhone Xʀ`;
  console.log(input.match(/^([\w\d\-\s]*)\x{0280}/));

1 Comment

This answer doesn't work as written, null is returned instead of an arrays of matches.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.