Jump to content

getPlayers filter name with spaces


Ragnar Lothbrok

Recommended Posts

getPlayers().filter(p -> p.getName().toLowerCase().equals("nospace"));

This works fine - the player if found if they're nearby.

getPlayers().filter(p -> p.getName().toLowerCase().equals("name with space"));

This seems to work randomly - some names work and others don't. Does anyone have any idea why that could be?

Edited by Ragnar Lothbrok
Link to comment
Share on other sites

21 minutes ago, Ragnar Lothbrok said:

Why would some names be like this and not others - doesn't make much sense but I'll give it a go thanks!

Cause \u00a0 is a non breaking space, as in if its at the end of the line it blocks the text editor from breaking the word. In other words, non breaking space is counted as a part of the word.

Also it should be username.replaceAll("\\u00a0", " ") because you need to escape the back slash.

Edited by Vilius
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...