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)

0
votes
2answers
43 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
36 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
147 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
322 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 ...
3
votes
1answer
32 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
62 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] ...
4
votes
2answers
226 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
37 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 = ...
1
vote
2answers
12 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
88 views

Problem with get all the link from String Regular Expression

Below is the regex I tried to get all the urls from string: ...
5
votes
2answers
87 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
74 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
45 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
26 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
30 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
35 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
39 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
54 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
354 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
137 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
56 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
94 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
155 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
50 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
49 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
188 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
41 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
182 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
282 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
312 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
45 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
94 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
78 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
231 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
138 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
37 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
74 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
537 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
612 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
239 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
237 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
372 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
85 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 ...
8
votes
2answers
374 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
113 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
216 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
1k 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 ...