VBScript Regex expression help in Excel VBA -
i need global changes number of spreadsheets , think best way use regular expressions have added reference microsoft vbscript regular expression type library , can process regular expressions. using function following signature:
regexpsubstitute ( target string, searchregex string, replaceregex string) string
i have number of cells contents this:
'alberts1:xlri_chem_chemical_1' * 'albert_chemicals_sg_lime' * 'albert_chemicals_conc_lime' * 'albert_lime_price' / 1000
all stuff starting "'albert_" need changed "'alberts1-" , other underscores in symbol need changed dashes. first part can with:
new = regexpsubstitute(old, "(')([^-:_ ]+)(_)([^']*)(')", "$1" & scadaprefix & "-$4$5")
but replaces first '_' '-' , need others in symbol. first symbol, starting "'alberts1:" should not changed.
at moment, thinking best thing split string symbols on space character , process each symbol separately, can whole thing in 1 search & replace?
sorry, no, regex engine supports infinite-length-lookbehind, , ecmascript engines don't that.
you'll have process each entry separately, , if starts albert_
, replacements on it.
Comments
Post a Comment