You need to sign in to do that
Don't have an account?

substring regexp in select query
Hi,
Is there any way touse substring and/or regular expressions in SOQL Select statements? The query I would like to do is something like:
new List<Account>([SELECT Id, Store_ID__c FROM Account WHERE Website = :domain_query])
Where domain_query is a stripped version of the domain. ie: google.com would be google
The Website field should therefor be stripped from http://, the country suffix and possibly www if it is there. http://www.google.com -> google
I could use a LIKE comparison and then use a loop to check for equality but that isn't a nice solution...
Any ideas?
Well, you can't do it directly in the SOQL, however Apex String objects have a replaceAll() and replaceFirst() method which support regular expressions.
Or, you could use split on a Period.
List<String> tmp = domain_query.split('\.');
domain_query = tmp[tmp.size()-1]; // take the argument before ".com"
Best, Steve.
All Answers
Well, you can't do it directly in the SOQL, however Apex String objects have a replaceAll() and replaceFirst() method which support regular expressions.
Or, you could use split on a Period.
List<String> tmp = domain_query.split('\.');
domain_query = tmp[tmp.size()-1]; // take the argument before ".com"
Best, Steve.
Ok, thanks