What is the best regex to remove the "password" an...
# cfml-general
m
What is the best regex to remove the "password" and "autopassword" words from this string and its values? fuseaction=view.account&aid=40&password=Test&autologin=somuser&autopassword=Test!123
t
((auto)?password=[^&]+)(?:&|$)
a
Eeek - passwords in URLs?
t
ours is not to reason why.....
a
No, but sometimes people try to solve the symptoms not the cause 🙂
💯 4
m
yeah i know 😂 bad very bad!
Thanks @thisOldDave & @aliaspooryorik 🙏
oh one more thing! That worked perfectly but I have an & at the end I need to remove
t
remove the final none capturing group (auto)?password=[^&]+
🙏 1
m
@thisOldDave :#ReReplace(cgi.query_string,"((auto)?password=[^&]+)","","ALL")#> Doesnt work if I remove that = have I done it wrong?
t
NoCase?
m
Tried that
What about if I do a second sweep so just do right function to remove last character?
the fact we picked tha same variable names freaked me out a bit
👁️ 1
m
Thanks guys! Much appreciated!
t
this will remove the & as well if thats what you wanted https://trycf.com/gist/5ac3750a49ce083c1e557fd44919cbec/lucee5?theme=monokai
🙏 1
a
this site is dead handy for seeing how teh reg works https://regexper.com/#%26%28auto%29%3Fpassword%3D%5B%5E%26%5D%2B
🙏 2
🙏🏼 1
m
Wonderful cheers guys!!#