1

I'm trying to get all letters in a string. But, sometimes, it matches two letters as one match, causing problems.

I think these strings that I'm using have invisible characters in them that are messing things up. Here is one of the strings I was using: "s͏uc͏͏ce͏͏s͏s". If you put that in https://regexr.com/ with ([a-zA-Z])+, it will mark "uc" and "ce" as individual matches. How do I get it to match each character as an individual?

example of problem

3
  • Not invisible, 00034F ͏ COMBINING GRAPHEME JOINER Commented Jan 26, 2019 at 16:39
  • Its a neat way to semi-mask the text Commented Jan 26, 2019 at 16:44
  • so I'm assuming if I remove all of those Unicode junk it will work properly? How do i do that? Commented Jan 26, 2019 at 16:47

1 Answer 1

1

Take away the +

The + is a way of denoting one or more elements fitting your sequence constitutes one expression

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

7 Comments

edit: ok so i tried that, but now when i eval "Th͏͏e͏ g͏͏ri͏t͏t͏y͏ ͏r͏e͏͏c͏e͏s͏s͏ d͏͏id͏͏n'͏t͏ ͏s͏e͏͏e ͏͏th͏͏e ͏͏be͏n͏͏g͏a͏l͏.".replace(/([a-zA-Z])/), i get "undefinedh͏͏e͏ g͏͏ri͏t͏t͏y͏ ͏r͏e͏͏c͏e͏s͏s͏ d͏͏id͏͏n'͏t͏ ͏s͏e͏͏e ͏͏th͏͏e ͏͏be͏n͏͏g͏a͏l͏."
With what are you trying to replace the letters?
I am using regex.
The replace function will replace all sequences meeting the definition of your regex.
The whole point of this really is to delete that stupid invisible unicode character, as sln pointed out.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.