Reputation: 25
How to add the dot to the last of regex and it's is the optional like:
public static final String REGEX_HASHTAGS = "([^|\s|>]*[a-z]{2}[0-9]+(\s|$|<)+)";
i want to catch the string like: cx10 or cx10.
Upvotes: 0
Views: 109
Reputation: 121840
Try this regex:
public static final String REGEX_HASTAGS
= "\\b[a-z]{2}[0-9]+\\.?\\b";
\b
is the word anchor, and looks like what you want given your initial regex.
Upvotes: 1