Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
0 votes
1 answer
20 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(...
user avatar
1 vote
1 answer
22 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 ...
user avatar
0 votes
1 answer
27 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 ...
user avatar
-3 votes
0 answers
32 views

Remove first 0 in String RutArreglado.replace('^0','');

I have a trigger and I want to eliminate first 0 of the String RutArreglado, How could I do that? RutArreglado.replace('0',''); trigger RutIndexado on Contact (before insert, before update) { ...
user avatar
0 votes
1 answer
51 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 ...
user avatar
0 votes
1 answer
33 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 ...
user avatar
0 votes
2 answers
41 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/...
user avatar
  • 3,177
0 votes
1 answer
45 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]+)$
user avatar
0 votes
1 answer
15 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 ...
user avatar
0 votes
1 answer
33 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+')(.*...
user avatar
-1 votes
1 answer
31 views

Formula to strip images from Chatter Posts [closed]

I am building email notifications from Chatter Posts. When the Post is created my notification Flow is writing the Feed Item Body to a Rich Text field on my Case which is included in my email. If ...
user avatar
0 votes
2 answers
38 views

Best practices for sanitizing string data with AMPScript

I have a CloudPage with a form consisting of a text field. When the user submits on the form, the text field data is captured within a parameter and posted for processing on another Cloudpage. The ...
user avatar
  • 13
0 votes
1 answer
66 views

How to stop replacing single quote ' in apex with space

I am trying to replace all characters expect below mention characters with space in Apex [A-Z a-z 0-9-,.&/'@()+# $: ] String customerName = jo&hn<>ji'o; String AccName = customerName....
user avatar
0 votes
0 answers
23 views

SSJS RegExp Are Broken? [duplicate]

The Regular Expressions in SSJS Email Studio seem to be broken or have different results than expected, Is anyone able to shed some light on this discrepancy and how I can work around this? Thank you. ...
user avatar
  • 189
0 votes
1 answer
82 views

How to use lookup fields using RegExp for search bar in LWC data-table?

Here's the link to the similar question How to filter Data in dataTable lwc based on the input in search bar? The above works fine with non-lookup fields but doesn't seem to be working in my case. If ...
user avatar
1 vote
0 answers
32 views

Replace whitespace in part of a string

I have cases which contain urls in the case description, and the urls contain whitespace. I need to replace the whitespace with %20 in order to make the links clickable from the case. Obviously the ...
user avatar
  • 13
0 votes
1 answer
36 views

Matcher.matches() is not working as expected

I am trying to match DateTime input using the Pattern and Matcher class of Apex but wasn't able to achieve it. I've created a regex for matching the Datetime input as follows and it matches the ...
user avatar
0 votes
0 answers
37 views

Validation rule on user input

I'm trying to restrict users of filling in certain values in a VAT field. I want them to follow the VAT convention PREFIX-NUMBER(ex. BE0121569515) I made a validation rule to restrict on character ...
user avatar
  • 113
0 votes
1 answer
76 views

Regex Validation Rule Help

Looking for help on correcting my validation rule on a First Name field. We want to allow A-Z, a-z, and then also allow apostrophe, hyphen, and period ('-.) When testing my formula below, it allows a ...
user avatar
  • 49
0 votes
0 answers
66 views

REGEX Syntax error in Error Condition Formula

I want to use a REGEX to check for valid phonenumbers including spaces etc. I found this REGEX here on Stack: /^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){...
user avatar
0 votes
1 answer
58 views

Apex Pattern, match everything (including new lines) between 2 passed parameters?

I'm trying to get a substring from a block of text that can contain new lines. Whats the regex needed to capture everything including newlines between 2 strings thats are passed in? The regex below ...
user avatar
-2 votes
1 answer
69 views

Regex Pattern not working

I not want the user to add the symbols in the opportunity column. I implemented the validation in the validator. But it is not working. NOT(REGEX(Account_Name_CAD__c", "^[#$%^&*+=-_/>&...
user avatar
0 votes
1 answer
78 views

Input Field Not Updating after calling .replace()

I have an input field on an LWC that should only accept numbers in the range [0-9]. I have a regex and a replace method. But the invalid characters only get removed after I enter a valid one. I could ...
user avatar
0 votes
2 answers
38 views

Not able to use the regular expression in Survey response validation - ^\d+(\.\d{1,2})?$

I am trying to add a validation in Salesforce survey response. User should be able to enter numbers up to 2 decimal places. Allowed inputs, 12 12.3 12.34 I am trying with ^\d+(.\d{1,2})?$ but I am ...
user avatar
0 votes
1 answer
67 views

Match the substring in a string and append the substring with #tags

I have a string in that match the substring and append the substring with #tag like #Test#; String str = 'This is a TesT for reteSt the tEsTing which will confirm that test was not TEsTed perfectly by ...
user avatar
0 votes
1 answer
31 views

How can I get "pattern"attribute from component (html) to Controller (javascript)?

How can I get "/ˆ[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}$/" in the Controller class? <label for="clientEmail">E-mail</label> ...
user avatar
  • 123
0 votes
1 answer
163 views

Not able to remove substring that is variable from a string

I want to remove everything except for Name. removeStart() and remove() don't seem to take variable as a parameter. String tmpField = '{!Contract.Name}'; String child = 'Contract'; tmpField = ...
user avatar
0 votes
1 answer
254 views

String.split() regex with colon

I'm trying to parse a set of questions and answers that are being written to a large text field in the following format Q1: question 1 A1: answer 1 Q2: question 2 A2: answer 2 etc... I want the ...
user avatar
0 votes
1 answer
262 views

Regex to validate text field which can contain number and alphabets both

I want to validate an input text field using pattern. I want my field to contain 0-9 a-z A-Z Please help pointing out the error in below code for the same <lightning-input type="text" ...
user avatar
0 votes
1 answer
111 views

How To Create a Validation Rule to Enter Whole Numbers in a Field?

I have a custom field called GMPI__c and I need to create a validation rule with the following requirements. User can enter numbers 0-9 only. The field is NOT required, so it can be left blank No ...
user avatar
0 votes
0 answers
285 views

REGEX formula to validate number field on Flow screen

I have a number field called "distance" on a Screen Flow. This flow is of type field service flow and not the traditional SF flow. I am trying to add validation for this number field such ...
user avatar
  • 4,521
0 votes
1 answer
170 views

Split the string from right side to get the required output after second occurrence of special character

I have requirement to get the string by splitting right side Ex 1.abc-sgd-ajj-test output needs to be in string = abc-sgd test-string-split-exam-demo output needs to be in string = test-string-...
user avatar
  • 7
-2 votes
1 answer
219 views

Dynamic SOQL with multiple conditions and undefined amount of variables

I have SOQL like this: [SELECT id FROM CONTACT where lastName =:lastName AND firstName = :firstName] But what to do if there are only lastName variable? What if there are 3 variables or more? I ...
user avatar
1 vote
1 answer
30 views

Regex Expresion

Hi can someone help me to put this regex in a validation rule NOT(REGEX( Video_Title__c, "[?\b(?:word)\b]?"))
user avatar
0 votes
1 answer
64 views

Write a formula to limit usage of special characters?

I have a requirement to validate a domain to not include all kind of special characters The characters I want to limit are: \ / + @ and some more (period is allowed) I was trying to use REGEX, but ...
user avatar
  • 5,435
0 votes
1 answer
408 views

RegExp in apex to get the text between curly brackets

I have below string My string {inside bracket} then again some other text {inside the bracket} I am writing regEx to get the text between {} there could be n number of curly bracket blocks below is ...
user avatar
  • 2,225
0 votes
0 answers
56 views

Where is the gap in my validation rule using REGEX?

I want to validate that Case Serial Numbers (origin !=web) are not less than 8 characters, never greater than 18, never = 11, 12, or 13 characters. AND they must be one of the REGEX statements below. ...
user avatar
7 votes
1 answer
1k views

SOQL query to fetch records with reserved characters ('*', '/', '(', ')')

Hoping there is a simple answer that I am overlooking. Currently, we are able to search for the following reserved characters with an escape sequence, eg a backslash character '\', in SOSL: & | ! ...
user avatar
0 votes
1 answer
522 views

Canadian Postal Code validation [duplicate]

I'm trying to bring together LEN and Regex but it's not working. I need to validate CDN postal code on the opportunity. We can only accept all caps and a space for a total of 7 characters I was ...
user avatar
0 votes
2 answers
368 views

Deploying Connected App - Copado Deployment error "consumer key is already taken" Unable to upload correct yaml file [duplicate]

I am trying to deploy a connected app to higher orgs through Copado but am getting the error as "Consumer key is already taken" and so for that am trying to create a yaml and upload it in ...
user avatar
-1 votes
1 answer
65 views

SFDC and REGEX Differences

New to REGEX, understand SFDC has some differences though I have not been able to tell why my expression works on test sites but not in a SFDC validation rule. I need to ensure a record name ends in -...
user avatar
  • 1
1 vote
1 answer
80 views

Extract and manipulate the string with Regex in apex

I need help a with building a regex for extracting a particular string and manipulating it. Here's the example Actual Input: ( 12s ) Agent K: Hello Guest, How are you doing today?<br> <br>...
user avatar
7 votes
1 answer
217 views

How to emulate SOQL LIKE matching in Apex?

I have a need to replicate SOQL's LIKE behaviour in Apex: The % wildcard matches zero or more characters The _ wildcard matches exactly one character Case insensitive including for cases where ...
user avatar
  • 129k
1 vote
1 answer
33 views

validation of flow field

I have a flow field (phone_private) and I want to validate if this field only contain numbers. I tried REGEX({!phone_private}, "[0-9 ]+") but the rule fires also if the field contain numbers....
user avatar
  • 431
1 vote
2 answers
479 views

Salesforce regular expression get id value from string from prefix and Name of the record

I am trying to parse the string to get the Record name which is auto number D-{0000} format (ex: D-345677) and record id which is 15 to 18 char length which prefix starts with(a7s7) and full id is '...
user avatar
  • 1,634
1 vote
1 answer
81 views

Having problem with apex regex

I need to find credit card numbers in a chat transcript inside its before insert trigger and x them out. I have the following regex(s) first one works in online tools for long strings containing new ...
user avatar
  • 596
1 vote
1 answer
111 views

Problem getting regex 'Not Word' to work with Apex string literals

I have this string 'Enterprise - SELA'; And I want to convert it to 'Enterprise_SELA'; I can do this with the regex: \W+ However original.replace('\W+', '_') throws the Illegal character sequence \...
user avatar
0 votes
1 answer
69 views

search forward slashes in a string in lightning component

i want to replace a string after it matches a series of forward slashes till end of the line in a lightning component but the regex won't work. ex - the string value: // this is an example. I want to ...
user avatar
  • 1
1 vote
1 answer
537 views

Why Salesforce does not accept my REGEX?

I have a RegEx created and tested in regex platforms, this one: ;.+$ If I check its functionality the result is okay, you could check it too in this link https://regex101.com/r/ocDofm/1/. The problem ...
user avatar
  • 157
0 votes
2 answers
32 views

Regex in validation rule to start with the alphabet QC followed by 3 numbers

Example - QC578 I need to create a VR using regex that allows user to enter only the input that starts with QC in caps followed by 3 numbers.
user avatar
  • 1

1
2 3 4 5
7