java - Understanding `+` in regular expression -
i have regular expression remove usernames tweets. looks this:
regexfinder = "(?:\\s|\\a)[@]+([a-za-z0-9-_]+):";
i'm trying understand each component does. far, i've got:
( used begin “group” element ?: starts non-capturing group (this means 1 removed final result) \\s matches against shorthand characters | or \\a matches @ start of string , matches position opposed character [@] matches against symbol (which used twitter usernames) + match previous followed ([a-za-z0-9- ] match against capital or small characters , numbers or hyphens
i'm bit lost last bit though. tell me +): means? i'm assuming bracket ending group, don't colon or plus sign.
if i've made mistakes in understanding of regex please feel free point out!
the +
means "one or more" of whatever follows.
in case [@]+
means "one or more @ symbols" , [a-za-z0-9-_]+
means "one or more of letter, number, dash, or underscore". +
1 of several quantifiers, learn more here.
the colon @ end making sure match has colon @ end of match.
sometimes helps see visualization, here 1 generated debuggex:
Comments
Post a Comment