Excel VBA RegEx Using * (asterik) + End-Points to Match Entire String -


why following return "data" , not "_data_5252014_"?

dim regex new regexp regex.global = true regex.pattern = "_data_*_" name = "ecmosso_data_12312013_results_tbl" msgbox regex.execute(name)(0).value 

i guess documentation indicates matches preceeds *, under impression regular expression yield "_data_12312013_" , not "data". there way accomplish want?

you're matching underscore, preceding — "zero or more" times.

instead, use token .* ( any single character "except newline" ). greedy * operator shoot end of string, backtrack last underscore want use *? non-greedy match meaning "zero or more — preferably few possible".

_data_.*?_ 

live demo


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -