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
2answers
8 views

Clarification about Regular Expression Limit

Can someone help me understand the following statement from the Apex Developer Guide? I'm trying to understand regular expressions, but this statement has me a bit confused, and I can't figure out ...
1
vote
2answers
60 views

Problem with get all the link from String Regular Expression

Below is the regex I tried to get all the urls from string: ...
4
votes
2answers
43 views

Apex Regex Extract Numeric Value from String

B"H I am unable to extract a consecutive set of numbers from within a (single line) string using ([0-9]+). However, surrounding it with match-all other does work (.*?[0-9].*). Can someone explain to ...
0
votes
0answers
12 views

Using Regex and substitute in salesforce in a formula field [duplicate]

Is there any way to find multiple blank spaces between two words and replace it with a single space on a formula field in salesforce.. Thanks in Advance
0
votes
1answer
42 views

Using Regex and Substitute in a formula field in salesforce

In salesforce,I have a text field which can accept any type of text For Example: Absolutely[space]Yes Absolutely[space][space][space]Yes Absolutely[newline] Yes Now I want to create a report and ...
0
votes
1answer
41 views

How to get certain data from custom rich text field

There is the following custom field called Url__c of type Account I am using and the data added to the field is mainly urls and websites. The problem is that the field is rich text and the data ...
-1
votes
1answer
23 views

Regex expression [closed]

Can someone let me know regex expression for below? I have an email template with below text. Template Body Dear {!Compliance_Incident_abv__c.RepEmail_abv__c}, What you need to know: New ABS ...
0
votes
1answer
21 views

Regular expression to find duplicate records

I would like to use a regualr expression on certain fields to detect possible duplicate records. for example the regx will detect all account records with the account name matching for than 50 ...
0
votes
1answer
30 views

understand REGEX Meaning

there is a validation rule, that i don´t fully understand, so can anyone please help me to understand the meaning of the REGEX credentials in the formular NOT(REGEX( BillingCity , ...
0
votes
2answers
34 views

Need help with regex for pick list where there are similar values between semi colons

This is racking my brain! In apex, I need to determine whether or not a specific sub-string is in a picklists value. So I'm trying to use the Matcherclass and the find() method using regex. My ...
0
votes
3answers
45 views

Regular expression for string

I have string like this. ,mon,,tue,wed,,,thu, I want out out put like this. mon,tue,wed,thu Is there any way to do this and store it in a string. Thanks in Advance.
2
votes
1answer
171 views

Replacing special characters with underscore doesn't work in apex. Works in Javascript

Replacing special characters with underscore in apex or trigger.I am using below things but getting error. string groupname=(gr.name).replace(/[^A-Z0-9]+/ig, '_'); Error: expecting a right ...
5
votes
1answer
112 views

Regex matches not being found…but they are there

I am using this code to loop through a Matcher and then add each match to a list. For some reason, the find() method is only finding the first 2 out of the 4 matches. I know that the pattern works ...
1
vote
1answer
34 views

Regex Match Count and Scan

Is there a way that I could print the contents of each regex match within a loop? Say I have the following pattern: 1xxxx2xxxx3 If I have a matcher that is (?mi)(\d)...How could I iterate through ...
0
votes
1answer
62 views

Help with REGEX function to prevent P. O Box in Salesforce Address Field

I have requirement to prevent a street address field in Salesforce from accepting any value that contains P. O. Box Post Office Box P o Box I thought the rule below would work fut for some reason the ...
0
votes
1answer
71 views

Replacing Regex Match with Blank space

This should be a simple question, but I cannot find the answer. I need is to replace my Regex Match with blank space. What is the Syntax for this? Here is my Expression: Matcher alphaSourceMatch = ...
1
vote
0answers
38 views

How can I convert my htmlBody to plainTextBody using Apex/Regex

The emails that are being recieved by my apex-email-service do not have plainTextBodies. Is there a way to convert HTML to PlaintextBody in apex?
0
votes
0answers
35 views

Localization - how to find all hardcoded string

I use Force.com IDE. I can scan for .cls and .resource for hardcoded strings. Can anyone recommend good RegExp to find them.
1
vote
2answers
160 views

Trying to get number of numbers in a string using regex

I have been trying to get the number of numbers in a string using regex, but without success. The following code returns me 0 groups in the expression. String expression = '1 OR (2 OR 3) AND 4'; ...
1
vote
0answers
34 views

Regex works fine in regex101.com but get failed in salesforce api

Can anyone suggest what is not compatible with salesforce in below REGULAR EXPRESSION: (?s)^\s*Contact received.*(?-s)(?<=Phone Number:)\s*(.*) TEST STRING: Contact received E-mail Address: ...
1
vote
2answers
130 views

System.StringException: Invalid regex: Illegal repetition {![a-zA-Z0-9_.]*}

{![a-zA-Z0-9_.]*} is not working when I use it as a regex in Apex: Pattern ptrn = Pattern.compile('{![a-zA-Z0-9_.]*}'); Matcher matcher = ptrn.matcher('{!Account.Name}'); Does anyone know why this ...
2
votes
1answer
174 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
247 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
40 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
69 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
69 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
196 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
117 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
35 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
68 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
459 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
491 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
24 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
177 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
193 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 == ...
1
vote
1answer
316 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
75 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
263 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
101 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
186 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
938 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
5k 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
350 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
265 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
109 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 = ...
5
votes
3answers
13k 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
4k 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
3k 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
601 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
288 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 ...