xcaliber13 Posted June 14, 2019 Posted June 14, 2019 Can someone tell me why this does not work? I have an array that works with no problems if I use a defined = "33282" For $i = UBound($aFinal) - 1 To 0 Step -1 If $aFinal[$i][7] = "33282" Then _ArrayDelete($aFinal,$i) EndIf But if I try to use regex (again I do struggle with regex) it does not delete the line For $i = UBound($aFinal) - 1 To 0 Step -1 If $aFinal[$i][7] = StringRegExp($aFinal[$i][7], '(?im)^A\N*\S\N*$') Then _ArrayDelete($aFinal,$i) EndIf Next Within my array in column 7 I am trying to delete any row that if the cell in column 7 begins with an A and has a different set of 4 numbers that follow the A Am I using the correct command? StringRegExp? If yes then what I am doing wrong with the regex? Thank you for any help.
FrancescoDiMuro Posted June 14, 2019 Posted June 14, 2019 (edited) @xcaliber13 If $aFinal[$i][7] = StringRegExp($aFinal[$i][7], '(?im)^A\N*\S\N*$') Then Since SRE returns 0 or 1 with the default flag (match), you are trying to resolve the equation "Is this value equal to 0 or 1?", so, if your data is not 0 nor 1, the set of instruction is never executed in the If statement, and so the elements in you array are not deleted. Try to change the line above with If StringRegExp($aFinal[$i][7], '(?im)^A\N*\S\N*$') Then ; Delete the line EndIf EDIT: 11 minutes ago, xcaliber13 said: I am trying to delete any row that if the cell in column 7 begins with an A and has a different set of 4 numbers that follow the A You could even use the pattern (?i)^A\d{4}$ Edited June 14, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
xcaliber13 Posted June 14, 2019 Author Posted June 14, 2019 FrancescoDiMuro, Dam It. I knew it had to be something stupid that I was missing. Changed it to your recommendation and it worked perfect. Thank you
FrancescoDiMuro Posted June 14, 2019 Posted June 14, 2019 @xcaliber13 Don't say that! "Errare humanum est [...]". Happy to have helped Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now