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)

2
votes
1answer
21 views

Regex Pattern to Isolate Multiple Double Quoted Terms

The pattern below allows me to isolate a single term that is enclosed in double quotes. However i'd like to be able to isolate multiple terms that are double quoted and separate them if possible. ...
0
votes
1answer
43 views

Regular expression in validation rule cannot find line breaks

I am trying to use the below regex in my validation rule. OR( REGEX(BillingStreet ,'(.+\n){4,}'), REGEX(BillingStreet, '.{60,}') ) I am attempting to force the street address to ...
1
vote
0answers
28 views

How to attach file using actionFunction

Could you help me please? I want to implement attaching files to Cases in SalesForce. There is recomanded way which using apex:inputFile element, but I can’t use it, because on page I have to use ...
3
votes
1answer
122 views

Regular Expression to find Chinese characters

If a string contains atleast one chinese character then i have return a boolean. I am looking for exact regular expression to use in pattern.matches method. Any help much appreciated.
1
vote
2answers
29 views

Regex to find first email after specific phrase

I received a request to write some regex to find an email address after a specific phrase (Buyer's email address:). But, the request didn't specify that the email COULD possibly be on a newline or ...
0
votes
1answer
30 views

REGEX with text and number both + salesforce validation

I have a peculiar requirement where I should check the user should either enter valid email or a valid 10-digit number. I have the below solution created: AND( NOT(REGEX ( UPPER ( ...
3
votes
1answer
30 views

Masking sensitive info in EmailToCase feed

I have written apex trigger codes on both Case and EmailMessage objects, which are both fired by before insert events. They run pattern and matcher classes to block several possible formats of a ...
3
votes
1answer
40 views

Regex problems in Apex

I'm especially terrible with Regex, but reworked one I found online to suit my needs, but it keeps throwing the "no viable alternative at character '\'" error. This pattern works when tested in ...
1
vote
1answer
25 views

REGEX expression generation

I have to restrict below entries by REGEX function in validation rule. Please let me know how to do that. I am unable to replicate the case. I need to put that part in below Validation Rule. String ...
0
votes
0answers
23 views

Include a string in REGEX

I have below error condition formula active in a validation rule. Formula AND(OR(REGEX(Name,".*(?i)(p[. ]?o([. ]?|st[ ]?office))[. ]?box.*")), NOT(ISPICKVAL(Address_Type_abv__c,"Mailing"))) String ...
1
vote
1answer
47 views

How to split String Using REGEXP or Using Pattern class

This is My String 14-Mar-16,RTRDTG78BGXPBE3H,D-Link DIR-600M Wireless N150 Home Router,10-Apr-16, SECEBH7HZMKZMG3B,Kaspersky Internet Security 2016 1 PC 1 Year I want to split this string Where ever ...
0
votes
2answers
91 views

Apex regex to get html child tag and its content? [closed]

I have below HTML tag and i need to extract TAG child tag and its element. <h3 class="large lheight20 margintop10"> <a href="https://google.com" class="marginright5 link linkWithHash ...
3
votes
2answers
62 views

Regular Expression in Apex to find entire link in string

I have a regular expression in apex that is only grabbing part of the link I need in a string. I need it to grab the entire link. Here is what im working with: String myvar = 'this is an example ...
3
votes
2answers
255 views

How to split a string by comma and single quotation mark in apex?

Following is a string: 'First Name','Last Name','Account Name','Email','Title','Description' and I want it to split with ",'" (comma and single quotation mark).
3
votes
1answer
329 views

How to make regex as reusable?

I have a regex which validates the user email address.I have used same regex in two controller classes. now my code is : if(!Pattern.matches ('([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]...
3
votes
1answer
53 views

Regex: Make Dot Match Newline?

I use Rubular to test my regular expressions, when I need them. I am having a bit of trouble crafting an expression that will work for me. For reference, I am trying to match multiple substrings in ...
3
votes
2answers
76 views

Regex: I need to get numbers inside square brackets my regular exp is working in online tester but not in console

If I try and test the same string it works fine in all the online regex testers but its not working in console. throwing me NOT FOUND Error. Can anyone guide me. string str='this is a test [12312] ...
5
votes
2answers
300 views

using regex in replaceAll to replace multiple char in one go

I have a phone number that i need to convert to a valid format to be send to a webservice validator. The phone number should be 10 char long and should contains only digits. For instance, I should ...
2
votes
1answer
47 views

Serialize JSON attribute that is a reserved keyword in Apex

To use the Javascript tree library DynaTree on my Visualforce page I create JSON data in its controller List<DynaTreeNode> rootNodes = nodesByParentId.get(null).values(); dynaTreeJson = JSON....
1
vote
2answers
16 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
130 views

Problem with get all the link from String Regular Expression

Below is the regex I tried to get all the urls from string: (?:(?:(?:[a-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[a-z0-9.-]+|(?:www\.|[-;:&=+$‌​,\w]+@)[a-z0-9.-]+)((?:\/[+~%\/.\w-]*)?\??(?:[-+=&...
5
votes
2answers
152 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
0answers
124 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
54 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
30 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
34 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
48 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 , "^[\\p{Ll}\\p{Lu}\\...
0
votes
2answers
41 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
60 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
603 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
154 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
69 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
139 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
264 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
1answer
66 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
62 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
227 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
44 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
253 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 ...
3
votes
1answer
414 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
361 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'; Pattern.matches(regEx,'...
1
vote
0answers
47 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. ...
-1
votes
2answers
109 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: AND(REGEX(FirstName&...
1
vote
2answers
95 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
273 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
149 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
45 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
83 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
582 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 ...