Questions tagged [regular-expressions]

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.

Filter by
Sorted by
Tagged with
3 votes
2 answers
125 views

How to use Custom Label in REGEX function in Validation Rule

I am able to use the regex formula string directly in the validation rule and its working fine when I tested it. AND( CONTAINS(RecordType.Name, 'International_Lead'), !REGEX(Phone, '^(\\+)\\d{...
Rival's user avatar
  • 601
-1 votes
1 answer
43 views

Create a conditional pattern for validating phone number in Screen Flow

I am using a screen flow to capture information that will create multiple records, and one of the fields I need to capture is a Phone field. Depending on a value set previously (Country), the phone ...
Lara Wasowski's user avatar
0 votes
1 answer
43 views

Aura Decimal Input value to match number field limit 16,2

I am trying to limit my input number field to exactly match the field values which are 16 digits to 2 decimal digits. Also I want to prevent user from putting something different into the field like a ...
YCS's user avatar
  • 15
-2 votes
2 answers
48 views

Stuck with a regular expresion

I have the following in Javascript and are trying to do this in apex but having issues .replace(/\s+/g, '-') // Replace spaces with - .replace(/&/g, '-and-') // Replace & with 'and' .replace(/[...
Thomas's user avatar
  • 2,294
-1 votes
2 answers
87 views

Seeking Guidance: Email Validation Error Handling for Specific Scenarios for field in account object

I'm facing an email validation challenge for my project. I want to throw an error if any of the following scenarios are met: The email has numbers at the end, like '[email protected]'. The email ...
HSD's user avatar
  • 1
-2 votes
1 answer
279 views

Regular expression for specific email address format in a validation rule

I have a regular expression which requires emails to be in [email protected] format. I want to tweak to be [email protected] OR fi[email protected] where 'i' would be ...
Aron Schor's user avatar
0 votes
1 answer
114 views

Validation rule to prevent more than a certain number of one character in a text field

Is it possible to include in a validation rule for a text field to only allow X amount of commas? I am trying to limit the amount of emails that are currently seperated by a comma.
needhelpplease's user avatar
0 votes
1 answer
55 views

Replacing specific text in Case field

I'm looking to basically redact some information in our Salesforce environment, across various fields and using different REGEX patterns. For example, in Case.Description, I have the following details:...
Nat's user avatar
  • 1
0 votes
1 answer
98 views

Ampscript for Uppercase hyphenated values

I've been trying to solve an Ampscript code, but keep getting the same results. What am I doing wrong? For /* Case 1: Uppercase hyphenated */ a) the original value looks like this A-BCDE b) the ...
O'Kiel's user avatar
  • 3
0 votes
1 answer
15 views

Regex Pattern to get Salesforce standard object supported calls not working

This regex pattern works everywhere except in Apex. Can anyone help me with this Http httpProtocol = new Http(); HttpRequest request = new HttpRequest(); String endpoint = 'https://developer....
xaero's user avatar
  • 1
1 vote
1 answer
248 views

How to remove symbol and space from a string in JavaScript [closed]

I have a string called myValue. let myValue= 'Premium+-+Mobile+Plan' And I need the output as Premium Mobile Plan I tried to use replace method. let myValue= 'Premium+-+Mobile+Plan' console.log(...
Archita Patnaik's user avatar
0 votes
2 answers
158 views

Regex for Aadhar card is throwing an error

used this for validating Aadhar card NOT(REGEX(Aadhar_Number__c , "[0-9]{12}")) and I'm getting this error Incorrect argument type for function 'REGEX()'.
Himabindu Jayanty's user avatar
-1 votes
1 answer
88 views

Remove HTML Table from Apex String

I have a String variable holding HTML Tables. Based on certain conditions I would like to remove the whole table having a particular class. String htmlCode = '<table class="table1"><...
Akash's user avatar
  • 361
-1 votes
1 answer
192 views

How to Check if a String Contains DateTime in Apex?

I have a String as below : String str = '<FirstName LastName> - <05-22-2023 08:00:34> - <LongText Description>'; I am trying to check if the string contains the datetime as above ...
SFDC Learner's user avatar
0 votes
0 answers
151 views

How to match Base URL in LWC with regex expression in JavaScript?

I have following two possibilities for Base URL - connect/X where X can be any of tankDetails, billingArrangements,foodsafetysolutions, quickList, orders, payments, insights, connectservices, ...
Amax1's user avatar
  • 109
0 votes
1 answer
319 views

Restrict the user to enter special character in string or Field

I have restricted the user to enter the space and size should be 20 digit, If some one can guide me to prevent the user to enter special character in apex..i am not able to find any solution to put ...
Shekher's user avatar
  • 11
0 votes
0 answers
35 views

REGEX validation ignored unless separate REGEX validation fires

I am working to validate the format of a string to 4 letters-3 zeroes-4 letters. On it's own, this REGEX() works fine: OR( /* check the leftmost 4 for any digit */ REGEX(LEFT(String__c,1),"[0-9]{...
Duncan Stewart's user avatar
0 votes
2 answers
115 views

Regex not working in class but works in execute anonymous

You can get some context here on my previous post. When I run the below code on execute anonymous, it renders the following result: String txt = 'Requesting service for Id Number 9202204720082, Case C ...
d_k's user avatar
  • 1,291
0 votes
1 answer
437 views

Regex for Case Number, South African Id and Passport

Please bear with me, I'm not well versed with Pattern, Matcher or Regex. I found the below on https://regex101.com/ South African passport: [A|D|M|T][0-9]{8} South African Id: (([0-9]{2})(0|1)([0-9])(...
d_k's user avatar
  • 1,291
2 votes
4 answers
2k views

REGEX in Salesforce Flow to retrieve a substring

I need to retrieve a substring from a text field in a flow. is it possible by using regex instead of apex ? If i try this regex i receive false as result ( boolean ), i should get true and then i ...
Brian23Gt's user avatar
  • 109
2 votes
1 answer
101 views

Validation Rule not running the whole formula

A field(Example__c, Text 255 char) can have a value of alphanumeric(numbers and/or letters) type and character length should ONLY be either: 3 character value 7 character value 12 character value I ...
Hatake_Kakashi's user avatar
-1 votes
1 answer
317 views

REGEX for combined alphanumeric ONLY strings of indeterminate length

We have an integration that is failing when special characters are included in certain text fields. I found NOT(REGEX(fieldName__c, "[a-zA-Z0-9]")) which works fine for a single character/...
Duncan Stewart's user avatar
0 votes
2 answers
208 views

String split on newline creates blank strings for every newline

I have a split on a newline which works fine, but it seems to create a blank value for every time it does a split, so 'MyText' contains the following values, separated by a newline: Blue Green Yellow ...
Irene's user avatar
  • 1,763
0 votes
0 answers
100 views

Need help in Javascript while using it in LWC with RegEx Salesforce

I need help with the below problem. I feel I have half the answer but the remaining half is the key. I have variables in JS and respective values in them: this.A => 'Name = Joy' this.B => ...
JOY DAS's user avatar
0 votes
1 answer
548 views

Regex / Pattern, Matcher - Exclude a specific Match

Related to the matching of IBAN Numbers: Given this regex pattern ((?:DE)[0-9]{20}) is there a way to exclude specifically the IBAN Number e.g. DE02120300000000202051 directly in the regex pattern or ...
Maserick's user avatar
  • 100
0 votes
0 answers
72 views

how to use a variable in a reguar expresion in apex?

I am using the following to parse the data of the Telefon from my description field in the case in Inboundemailhandler. Pattern urlPattern = Pattern.compile('(Telefon)\\W*\\d*'); Matcher m = ...
Cathy's user avatar
  • 73
0 votes
0 answers
42 views

Regex for the field validation

I have created a Regex expression for the custom object's custom field Worksite_Street__c and Worksite_Street_2__c that can only contains number, alphabet (small and capital) and #,'-:_@/(). these ...
user avatar
-1 votes
1 answer
283 views

create a validation rule that ensures either a single email or a multiple emails are comma separated with correct email format

I created this Regex and tested it on online regex tester. But when I am using the same regex in salesforce validation rule then I am unable to save it due to "Error: Syntax error" The Below ...
Reettik 's user avatar
0 votes
1 answer
480 views

Regex to find dd/mm/yyyy

I have a pretty simple code and in one case it works, and not in all the case, I wanted to know what I'm missing I'm trying to match a date in this format dd/mm/yyyy This is my code: String d = '20/03/...
Yaac0's user avatar
  • 155
0 votes
1 answer
100 views

REGEX too complicated in breaking a soap API response

I am working on an apex class that makes a soap API callout and receives a response. To see the complete response in debug logs, I am using a splitString() method to break down the XML response at nth ...
Balaji Pooruli's user avatar
-1 votes
2 answers
93 views

Extract data from string and reframe it into another

I have got a string in below format: String test = '11, -22|32.45, 34|32, 41|32, 12.12'; I am trying to convert it into below format: {"a":11,"b":-22|"a":32.45,"b&...
user15754268's user avatar
-2 votes
1 answer
1k views

Regex for US Federal Tax ID (EIN) [closed]

In the pattern attribute of an input tag, I am using the following regular expression for validation of the US Federal Tax ID field. pattern="^[1-9][0-9]{8}$" But this regex allows ...
Rajiv Singh's user avatar
0 votes
1 answer
385 views

Compilation of Regex in Apex

I am trying to compile following regex /^[~`!@#$%^&*()_+=[]{}|;':",./<>?a-zA-Z0-9-\w\s]+$/ String fileNameRegex = '/^\[~`!@#$%^&*()_+=\[\]\{}|;':",.\/<>?a-zA-Z0-9-\w\s\]...
Nachiket Deshpande's user avatar
-1 votes
1 answer
959 views

Contains or Regex in formula for checking multiple values

I'm writing a formula to check of a field (for example, "Country"), contains one of many values. Example: CONTAINS(“Massadonia Republic:Dominican Republic:US:UK”,Country) From what I'm told ...
user1702965's user avatar
0 votes
1 answer
203 views

Pattern.quote matches substring instead of whole word match

I was trying to implement a case insensitive whole word searching pattern. I came up with the following pattern: Pattern p = Pattern.Compile('(?i)'+Pattern.quote('af')); Using it in the code below: ...
Aman Sharma's user avatar
3 votes
1 answer
597 views

Regex to match single to double digits

I am trying to replace all digits with {digit}, but the issue is double digits are getting replaced incorrectly. For eg: String str = '1 AND 2 OR (3)'; Pattern p = Pattern.compile('([0-9]+)'); Matcher ...
Nagendra Singh's user avatar
2 votes
2 answers
893 views

RegEx pattern matcher issue

I'm struggling with a "simple" RegEx problem. I wan't to check a sting if the pattern "BN123456" or "bn123456" is included and if so, extract it. The pattern could be in ...
Maserick's user avatar
  • 100
0 votes
1 answer
1k views

Aadhaar card validation rule not working using Regex in salesforce

I'm basically having validation rule in salesforce to check the whether entered value is in required format or not. However in below formula validation formula for Pan Number is working fine but for ...
Sachin Kulkarni's user avatar
2 votes
1 answer
371 views

Regular Expression is matching non-whole words despite leveraging \b within the expresion

I am having a regex replace issue where the regex statement is matching non whole words. In the below example I have the word 'cormand &'. When I run the regex statement, it return 'corm &'. I ...
Matthew Metros's user avatar
0 votes
1 answer
274 views

Pattern Matcher problem

I want to get the sub string 'fact.cm_comp_sales_adjustment_factor__c.living_area_default_index_score__c' in the string '[subj.cm_parcel__c.sqft__c]+[comp.cm_sale__c.sqft__c])*fact....
Tuấn Trần quốc's user avatar
0 votes
2 answers
3k views

Regex for Email List on Salesforce Validation Rule?

**UPDATE 22 June 2022 For simplicity sake, I will edit my question to have emails separated with just semicolon e.g. [email protected];[email protected] So I have this Long Text Area field to capture multiple ...
compski's user avatar
  • 1,251
0 votes
1 answer
3k views

How to validate Mobile Number with Country code followed by 10 digits

I am new to salesforce . I have MobilePhone field in Contact. I need to validate the MobilePhone Field such that it must include (+1, +91, +355) followed by 10 digits mobile number. NOT(REGEX(...
Sanjana Rajasekar's user avatar
1 vote
1 answer
73 views

How to optimize Searching bulk data for list of words

I have a spam detection mechanism which searches strings of word in posts. The List can be 500+ entries long sometimes. I have a naïve searching algorithm //Unnecessary logic have been removed public ...
AmanSharma's user avatar
0 votes
1 answer
1k views

Regex for Lightning Input in Aura Component

I have one Lightning input in which I have to show the error message if condition is not satisfied. 1.4 characters min 2.12 characters max 3.Allowed characters: Letters (A,B,M....26 capital letters of ...
hemankshree's user avatar
1 vote
1 answer
626 views

LWC issue with replacing first invalid character

In my LWC, I have a text input where I need to prevent the user from entering anything besides a number or a decimal point. The Javascript function I'm using does replace the invalid characters with ...
Michael Sobczak's user avatar
0 votes
1 answer
783 views

Salesforce Regex - Return List of Matches

I have the following String: "Trastuzumab IV (Herceptin): Request change to Trazimera or Monoferric" I am using the following regex: (?<!\()\b(Trazimera||Monoferric)\b(?![\w\s]*[\)]) I ...
Matthew Metros's user avatar
0 votes
2 answers
5k views

Removing leading zeroes in Date String

I have checked a number of posts and regex examples but for some reason I can't get the leading 0's to be removed from the date string below. Can anyone see what I am doing wrong? wanted result: 4/6/...
Olivia's user avatar
  • 3,429
0 votes
1 answer
5k views

How to exclude Test files From Searches in VS Code?

Is it possible to exclude test files when doing a grep search in VS Code? I would have thought one of these regexes would have worked ^/(?!Test$)[a-z0-9]+$ Or ^/(?!Test)([a-z0-9]+)$
PartOfTheOhana's user avatar
0 votes
1 answer
156 views

Regex Pattern to Locate first instance of Email response - On ..... wrote:

I have a field to store the Latest Comments on a Case. For email responses I would only like to store the current email response and not all of the historic replies. Most of my email responses are ...
Jeff Callahan's user avatar
0 votes
1 answer
366 views

Unable to match group in apex regex

I am trying to dynamically match a string against other string. String badWord = 'badwords'; String comment = 'I talk badwords and goodwords'; Pattern MyPattern = Pattern.compile('((.*)('+badWord+')(.*...
AmanSharma's user avatar

1
2 3 4 5
7