-
Notifications
You must be signed in to change notification settings - Fork 501
Text slug #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text slug #369
Conversation
Not sure, if this is what was requested though ;) |
src/main/java/apoc/text/Strings.java
Outdated
public String slug(@Name("text") String text, @Name(value = "delim", defaultValue = "-") String delim) { | ||
if (text == null) return null; | ||
if (delim == null) return null; | ||
return text.replace(" ", delim).replace(delim+delim, delim); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably use replaceAll("\s+",delim) for all whitespace
or \W+ for non-word-characters
Looks good, please have a look at my comment. Perhpas also test for subsequent space? |
Better like this? :) Anything else to improve? |
something is wrong now, there is a lot of other changes, can you rebase your work onto the latest master state? and then push to the PR branch again |
sure, sorry :) |
src/main/java/apoc/text/Strings.java
Outdated
public String slug(@Name("text") String text, @Name(value = "delim", defaultValue = "-") String delim) { | ||
if (text == null) return null; | ||
if (delim == null) return null; | ||
return text.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's actually much easier `.replaceAll("[\W\s]+","delim")
Thanks a lot !! |
I found a problem, the slug is not set to lowercase. |
Implements #343