Trying to write a regular expression for java that will return true ONLY if the term is included @ the beginning of the string (to be used for an auto-complete). So if my term was ‘work’ I would want it to return false for ‘homework’ but true for ‘workers’. Even the term ‘wo’ should be true for ‘workers’. Can anyone help? Any info much appreciated.
Also not sure if it matters, they might have these special characters as part of the auto complete term (, ), -, ., :, /, _, and spaces.
Use the
startsWithmethod. Regexes are overkill here. For exampleis true, as desired.