var aCompany = ['Smith-Kline', 'Smith-Burton', 'Williams-French'];
var testExp = new RegExp("/^" + companyName + "\-/i");
for(var i = 0; i < aCompany.length; i++) {
if((aCompany[i]) && (aCompany.match(testExp))) {
...do something
}
}
Although “Smith-Kline” should match on /^Smith-/i, it doesn’t in the code. Using the interactive console, however, I can get a true value on aCompany*.match(/^Smith-/i).* I also tried defining testExp = “/^” + companyName + “-/i”; however, that didn’t work, either. What will get this to work? Thank you, Don
var recordExp = new RegExp(record_uid.toString());
recordExp.ignoreCase = true;
If i test it in the interactive console, Servoy appears to not honor the ignoreCase request. A match() later in the code fails even though the only difference is case. However, it will work if I try instead to match on record_uid.toString().toLowerCase().
The UIDs are Servoy-assigned, and contain the dashes.
But when the UserManager plugin returns the record UIDs as a dataset of locked records, the UIDs are lowercase. I am trying to match up the returned UIDs with a particular record’s UID (to see who has locked the record).
So to make .match() work, I would need to replace each instance of a “-” with a “-” ?
djlapin:
I would need to replace each instance of a “-” with a “-” ?
Yes, because if you have an uuid containing for example 1-4, then it doesn’t match the string “1-4”, but only the strings “1”, “2”, “3” and “4”. So that will give you strange results.
My favorite comment on this subject is, “Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.”