A regular expression (abbreviated regex or regexp) is a sequence of characters that forms a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. "find and replace"-like operations.

learn more… | top users | synonyms (1)

1
vote
1answer
17 views

Catch Regex too complicated when splitting a string in salesforce

I have created a function wherein I split a string from the csv filecsvAsString.split('\n') . It is working when the string is not so big. But when I try to split a very large string, an error will ...
2
votes
1answer
104 views

Regular Expression for words with spaces

I want to check for the following strings using regExpression: 1) Main-xxxxx-Accepted 2) Main-xxx xxx-Accepted I used the below String regEx = 'Main-[aA-zZ-]*-Accepted'; ...
1
vote
0answers
36 views

Opportunity name validaiton by using the Regex method in Validation rule

I have used the below code for check the field value should be the title case. it is working fine but when I entering capital letter for all text, it is not throwing the error. but it should through. ...
-2
votes
2answers
21 views

REGEX work for initial space with string

I have a requirement to find a string('Mc') which either present at begining of the field value or after a space. Can someone help as my code fails for 'hemchand'. REGEX Code: ...
1
vote
2answers
36 views

RegEx in use with an InboundEmail.htmlBody String is not matching a Pattern

Apologies for the poor formatting; first time poster. I'm working with an InboundEmail object being sent it from a form from one of our internal systems - it's basically just sending an HTML email ...
6
votes
1answer
93 views

Validation Rule to count words

What I'm trying to do a validation rule to count number of words in a text field and return an error if field have more than 80 words. Validation Rule Condition Formula NOT(REGEX(TRIM( ...
1
vote
1answer
64 views

Regex Pattern/Matcher optional html attributes

So I am trying to make a pattern matcher that would read a block of html and identify the labels and ids of certain fields on the page. I am trying to find a way to read the label tag and parse ...
1
vote
1answer
22 views

Need help with the REGULAR EXPRESSION (REGEX) to format the strings [closed]

Just need to take off the unwanted characters from the erroneous string and need to store that as meaningful result. parse/split the error data value into a list of strings of the numbers below using ...
1
vote
1answer
38 views

Do APEX Regex patterns support named groups?

Do apex regular expressions support named groups? Similar to http://download.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#group%28java.lang.String%29? Example (?<name>X) The ...
2
votes
1answer
155 views

Regex in the validation rule

There is a field for 6 digit serial number in a record. Since the field can contain only numbers, I have created a validation rule with regex to check only numbers are entered in the text field. But ...
1
vote
2answers
146 views

REGEX Pattern for “PO BOX”

I have a requirement to create a validation rule on custom object Address_vod__c. There is a picklist field in the object,'Type'. If 'Type' value is not 'mailing' then restrict to create or edit ...
0
votes
0answers
22 views

categorizing data of different formats with in same datatype

I am trying to achieve a strange case where i can see rows of different formats of data in an object . Eg if i select phone number field on account, i need to get view of all the records which are ...
0
votes
1answer
60 views

Regexp to match square bracket

I've got this regexp that I found in this thread that does not exactly working for me, I get System.StringException: No match found. Basically, I want to get everything between [ ]. Pattern brackets ...
2
votes
1answer
89 views

Regular Expression is not working in apex

I'm trying to match a string with Pattern/Matcher. I want to extract sub string from a string. could anybody give me the solution to match the following sub string? <!-- if(Rajendra Patel == ...
0
votes
0answers
52 views

Update DML statement with Regular Expression match between characters

I'd really appreciate some help on this trigger please - here's what I'm trying to do and the code so far. Thanks in advance for your help. Custom Object: NVMStatsSF__NVM_Call_Summary__c Field: ...
1
vote
1answer
165 views

regex too complicated error when using split function for less than 1M characters

I am working with an attachment in Salesforce. this is a text file with 7291 rows and each row has 94 columns. I am able to read this attachment record as "Attachment". I am also able to convert ...
1
vote
0answers
55 views

Regex to hide html tags

I have one field Long text in which I have to escape HTML tags, I am able to escape HTML tags using REGEX but problem is if Content in field has gretaer than(<) character , this charcter is also ...
6
votes
2answers
142 views

replace characters while keeping original parts

Is there an easy and elegant way to add characters in a String at specified places around found characters? The way I started thinking was like this: String regExp = '[\\d]'; String toFormat = '1 ...
1
vote
1answer
68 views

How to generate REGEX for a pattern [closed]

I am validating a string with a REGEX pattern. '12345.12345'. The pattern should come NUMBER . NUMBER. I was trying with '[\\D]', but it will not be OK, because I want to use '.'. Any help?
2
votes
2answers
106 views

Opportunity product validation

I want to create a validation rule at Opportunity product to validate the following. Opp record Type – sample And Stage not equal to ‘Pending Approval’ Product or product code(item number) ends ...
0
votes
1answer
571 views

Validation Rule for Phone Numbers

I'm trying to create a validation rule for our phone numbers. Every number has 3 parts: Country Code (numerical, min. 1 digit, max 3 digits, starts with '+') Area Code (numerical, min. 1 digit, max ...
0
votes
2answers
2k views

Regex Pattern/Matcher to match a exact word

I am trying to build a regex pattern using the Pattern and Matcher classes in salesforce to find a exact match of a word . For eg. the word hot should be found in the 1st 3 string but not in the 4th ...
4
votes
1answer
250 views

Regex to validate Credit Card numbers

I have created a validation rule on a Log Text field, to check for Credit Card number for all major companies "(VISA, Master Card, Discover and Amex for now). Here is the validation rule: NOT( ...
3
votes
0answers
171 views

regEx + search capability in sfdc platform

Looking for suggestions on accomplishing search + regEx in sfdc, to search cases which have occurrence of the phrase 'PROVIDED BY:' in case history and get the case number where this phrase was found ...
3
votes
0answers
77 views

How can I use Pattern and Matcher instead of split() to do this?

I have the following function: @testVisible private String selectBeforeKeyword (String remainingStepsAsString, String keyword) { List<String> splitList = ...
4
votes
3answers
7k views

Making regex case-insensitive

I have created some lines of code for an email handler that will scrape my emails for a particular string (STA0123). Code: // Find STA No. (in email body) Opportunity Opp = [SELECT id, STA_No__c ...
4
votes
2answers
1k views

How to split a string by comma and white space

I have a string, I want to separate it by ',' and white Space, if it has any. This is what I have done : String s = 'Donate, Pricing,BOM'; List<String> stringList = s.split(",[\s]*"); ...
0
votes
4answers
2k views

how to show the validation error below the input field in VF page

I have used the following code for the email validation and the validation is working fine but I would like to show the error like the the image. how to do that? My Code: <apex:pageBlock ...
7
votes
1answer
581 views

How to replace 'MyFirstName' by 'My First Name'

Is there any easy way, by using regex and replaceAll method, to tranform MyFirstName by My First Name. I know I could loop through each character but I was wondering if it was possible to do that in ...
3
votes
1answer
204 views

Parsing “RE” and “FWD” in email subject lines

I'd like a sanity check on a regex modification I made. The below code parses out leading "Re:" and "Fwd": in an email subject line and captures the remainder of the subject line. It works, but ...
2
votes
3answers
2k views

How to find all numbers in a string using Regex

I am trying to extract all numbers from a string but I got the below code to work although it stops after the first match for 123. String str = '123-456/7890'; Pattern p = Pattern.compile('(\\d+)'); ...
1
vote
1answer
129 views

Regex to validate a generic CSV

I have two questions in order to make a custom csv importer in VF/Apex. I saw many samples out there but I'm not able to find validations samples. 1) I would like to know if is any regex to validate ...
2
votes
1answer
267 views

Complete Regex Reference For Salesforce Formulas?

Is there a complete Regex Reference somewhere for using REGEX() in formulas? I have searched and found nothing useful. The problem I am having is below. I want to know if any of the characters ...
0
votes
2answers
5k views

Regex Validation rule for telephone number

I want to create a validation rule on Phone field(Custom) where system will be allowed to use + or 00 and then 7 to 26 digits(Numeric). Also in between if I enter any space or dash that should not be ...
1
vote
1answer
145 views

Strange behaviour of Regex to allow only alphabets in the name field

I have a validatio rule on contact which gives error when the name field contains non-alphabetic character. Formual for the Vaildation rule is as follows : OR( REGEX( FirstName , "[a-zA-Z]+"), ...
3
votes
6answers
14k views

Best REGEX for first/last name validation?

Looking to stop people putting initials in the First / Last name fields, plus any special characters that you would not associate with a name. I've got something, although it is coming unstuck on ...
2
votes
2answers
1k views

Finding substring with regex for contents of <tr> tags

I am using regex patterns to search this string: ...
1
vote
2answers
2k views

Check if string contains specific characters- Validation Rule

I have a field text that cannot contain either l m or p whether it is upper or lower case. How can I accomplish this in a validation rule? Please give examples. Perhaps a regular expression example ...
0
votes
1answer
150 views

REGEX for stripping http://, https:// and www from website

For a custom field "Domain," I want to strip extraneous elements like those in the subject line, which often end up in the field through web-to-lead. Can anyone suggest a REGEX formula for stripping ...
0
votes
1answer
298 views

Replacing multiple consecutive spaces with Pipe character

I need to replace multiple consecutive spaces with pipe character ,I tried various regular expression but i couldn't get the output .Can anyone give me solution for this
0
votes
2answers
1k views

Extracting special character in salesforce Apex

I Have a string like "Hello-how@are you!" I want to get which special characters the string contains I searched for an hour i able to get the thing like replacing the special characters But i need ...
3
votes
1answer
322 views

Matcher not finding text within <> (e.g., HTML tag)

Does anyone know why the Matcher in Salesforce does not find text contained within <> (the "less than" and "greater than" signs)? The sample code below, adapted from "Using Patterns and ...
3
votes
1answer
516 views

SFDC regular expression to catch the word with repeated characters

I am going to use the regular expression to catch the word with repeated characters (letter, digit, or underscore). I found pretty interesting results during my testing. If I am using apex code, ...
4
votes
2answers
2k views

How do you check email format in Apex?

If I have a form for candidates to apply for certain jobs online, when a candidate enters his email and submits the form, I want my controller to validate the email format that was entered. Can ...
0
votes
1answer
639 views

I need a regex to find line breaks in a text area field in salesforce

I have a field of type 'Text area' With a paragraph of sentences with line breaks.it looks like this : "test regex for Text area with line breaks" The regex i used is : ...
4
votes
3answers
163 views

Regular Expression and Matcher issues

Does anyone know why this will not find the match. I'm running this code public string cleanEmail(String body){ String result; String RegExp = ...
2
votes
1answer
221 views

matcher.groupCount() always returns 1

I try to extract all mergefields out of an email template, but my matcher just finds the first one. groupCount is always 1. Im new to salesforce. Please help. pattern mrgflds = pattern.compile ...
3
votes
1answer
366 views

Regex a datetime from JSON and convert to miliseconds

I've JSON like this: "to" : "2013-11-28T20:58:00.000+0000", Which I want to make into: "to" : "/Date(1296547200000)/", The furthest I got with regex is replaceAll('(?m)(?i)"from" : "(.+?)("$)', ...
7
votes
3answers
2k views

Unable to use multiline with pattern

I'm trying to match a string with Pattern/Matcher, however it is failing because I cannot set Pattern.MULTILINE like the Java documentation uses. String testString = 'Line 1: Does not match\nCustomer ...
-2
votes
1answer
2k views

Pulling picklist options from a multi-value field

I am currently pulling select options for a multi-value picklist from a query which gathers field values from all of the child records from a certain __r relationship of an account. I would like to ...