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
1answer
26 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 ...
0
votes
0answers
34 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 ...
0
votes
1answer
23 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 ...
0
votes
0answers
26 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,}\)?[\-\.\ \\\/]?){...
0
votes
1answer
31 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 ...
-2
votes
1answer
42 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", "^[#$%^&*+=-_/>&...
0
votes
1answer
38 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 ...
0
votes
2answers
32 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 ...
0
votes
1answer
55 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 ...
0
votes
1answer
21 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> ...
0
votes
1answer
68 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 = ...
0
votes
1answer
73 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 ...
0
votes
1answer
34 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" ...
0
votes
1answer
43 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 ...
0
votes
0answers
122 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 ...
0
votes
1answer
67 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-...
-2
votes
1answer
93 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 ...
1
vote
1answer
29 views

Regex Expresion

Hi can someone help me to put this regex in a validation rule NOT(REGEX( Video_Title__c, "[?\b(?:word)\b]?"))
0
votes
1answer
52 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 ...
0
votes
1answer
195 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 ...
0
votes
0answers
52 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. ...
7
votes
1answer
811 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: & | ! ...
0
votes
1answer
307 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 ...
0
votes
2answers
213 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 ...
-1
votes
1answer
52 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 -...
1
vote
1answer
53 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>...
7
votes
1answer
157 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 ...
1
vote
1answer
26 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....
1
vote
2answers
319 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 '...
1
vote
1answer
49 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 ...
1
vote
1answer
96 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 \...
0
votes
1answer
35 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 ...
1
vote
1answer
431 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 ...
0
votes
2answers
17 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.
1
vote
0answers
29 views

Trying to String.split on new line after matched substring [duplicate]

I have a script that is hitting a System.LimitException: Regex too complicated Error and so to combat this I've come up with a solution to chunk up the string and then do the regex to the chunks so ...
0
votes
0answers
103 views

Regex too complex for JSON response from External System

I am getting "Regex too complicated" error when i am trying to make a callout with "getPassenger" method .to me, it seems the JSON response is big enough.I need to call this ...
0
votes
1answer
25 views

Extract 7 numbers out of a random string

I try to extract 7 numbers (a contract number) out of a random string using regex: pattern contractNumberPattern = pattern.compile('[0-9]{7}'); Matcher contractNumberMatcher = contractNumberPattern....
0
votes
2answers
91 views

Regular expression not working with Apex class while working in JS

I have a regular expression: \d+|[a-z]+. What this does is, if you have 81a, it splits into 81 and a. I have tested it on Regex101 and it works fine. I use it in my JavaScript code using match and ...
0
votes
2answers
330 views

Regular expression to check does a string contains any special symbols not working in lightning javascript

i am using the below code var value = 'abcd$'; var regularExpression= new RegExp('[-!$%^&*()_+|~=`{}\[\]:";\'<>?,.\/]'); if(regularExpression.test(value)) { //true } else{ false } ...
0
votes
1answer
398 views

REGEX Validation Rule to prevent duplicate in set of numbers

I'm working on a validation that would require a user to enter only numbers that have to be exactly 9 numbers and be separated by lines. The below is working for that, but is it possible with straight ...
1
vote
1answer
111 views

Regex for minimum characters in long text area field

There is a screen flow in which I have a long text area field. For that field I want to check that there are at least 5 characters entered in that field. I was using the regex - REGEX({!Case_note},“^.{...
0
votes
1answer
190 views

Understanding regex behavior with Lightning Input [closed]

I'm new with all the LWC topic. But for now I'm having issues with some regex. To Begin with I have my own LWC created with a few fields some of them are type number such this one: <lightning-input ...
0
votes
1answer
160 views

Regex to check for a space before a set of numbers

I am working on a validation rule (potentially looking into other methods later) that will prevent users from putting a credit card number or social security number in a text field. The issue i am ...
0
votes
1answer
2k views

How can i match second-last char of a string with RegEx

Angular app! I need to hide the 2 second-last char of a string and replace them with "XX". what i got: +391234567890 what i need +39123456XX90 How can i match this with a RegEx? I want to ...
1
vote
0answers
86 views

How can I use RegExMatch to minify CSS?

The use case is that I have created an email template in SFMC, and I am including the CSS via %%=ContentBlockByID('xxxxxx')=%% I would like to use RegEx to minify the CSS at the point which it is ...
0
votes
1answer
49 views

What is the main reason for Heap size limit error?

I am trying to upload a document that is less than 1MB in size but it has 5000+ records with 6 columns of fields, I am getting below error Regex too complicatedError is in expression '{!ReadFile}' in ...
0
votes
1answer
222 views

Validation rule to prohibit several words in a text field

I am looking for a validation rule (to prevent coding) that prohibits certain words (in my case Department names in a Contact FirstName field) I want the list to be easily maintainable, so I hoped to ...
0
votes
1answer
76 views

Validation rule to restrict up to 3 repetitive characters [closed]

Can anyone please give me a Validation Rule syntax may be using REGEX to stop the duplicate 4 characters in a standard field.? Basically the field can accept aa, aaa but not aaaa. I want to restrict ...
0
votes
1answer
45 views

RegExMatch doesn't seem to be working correctly

I am trying to strip anything including angle brackets out from a string of text via Regular Expressions. I have the below variable set: set @messageText = 'Hello, Chris John,<br><br>John ...
0
votes
1answer
371 views

phone field validation for starting with + followed by country code and phone number

I am trying to implement the phone validation for lightning flow screen. Here is what i tried and it's working in https://regex101.com/, But when am trying to save in lightning flow screen input ...

1
2 3 4 5 6