Fixed regex.

This commit is contained in:
Alex Ning 2019-08-27 09:29:18 +08:00
parent 3d50afd139
commit fe82b5686e
2 changed files with 5 additions and 5 deletions

View File

@ -31,9 +31,9 @@ public class LinkResolverActivity extends AppCompatActivity {
private static final String POST_PATTERN = "/r/\\w+/comments/\\w+/{0,1}\\w+/{0,1}";
private static final String COMMENT_PATTERN = "/r/\\w+/comments/\\w+/{0,1}\\w+/\\w+/{0,1}";
private static final String SUBREDDIT_PATTERN = "/r/\\w+/*";
private static final String USER_PATTERN_1 = "/user/\\w+/*";
private static final String USER_PATTERN_2 = "/u/\\w+/*";
private static final String SUBREDDIT_PATTERN = "/r/\\w+/{0,1}";
private static final String USER_PATTERN_1 = "/user/\\w+/{0,1}";
private static final String USER_PATTERN_2 = "/u/\\w+/{0,1}";
@Inject
SharedPreferences mSharedPreferences;

View File

@ -2,7 +2,7 @@ package ml.docilealligator.infinityforreddit;
class Utils {
static String addSubredditAndUserLink(String markdown) {
return markdown.replaceAll("(?<!\\w)/*u/\\w+/*", "[$0]($0)")
.replaceAll("(?<!\\w)/*r/\\w+/*", "[$0]($0)");
return markdown.replaceAll("(?<!\\w)/{0,1}u/\\w+/{0,1}", "[$0]($0)")
.replaceAll("(?<!\\w)/{0,1}r/\\w+/{0,1}", "[$0]($0)");
}
}