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
1
vote
1answer
52 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
18 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
243 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
12 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
22 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
38 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
17 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
28 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
0answers
19 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
33 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
36 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
40 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
58 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
28 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
28 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
33 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
40 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
44 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
37 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
54 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 ...
0
votes
1answer
51 views

Salesforce Apex Regex too complicated error [duplicate]

I am working on an apex class which is making a webservice callout to an external system and with the response that I get, I am updating couple of fields on the Account object. Unfortunately, this ...
1
vote
1answer
16 views

Regex Parsing failing to parse links

Here is the discrepancy Here is the parser function addPhoneLinks(str) { (str.match(/(\d{3})-(\d{3})-(\d{4})/g) || []).forEach(tel => { str = str.replace(tel, `<a href="tel:${tel}"...
-1
votes
1answer
45 views

Required REGEX for a String

I am trying to find a solution to validate below string in APEX, is there any regex that can be used ? SDI001 AND SDI002 --> This is valid (SDI001 AND SDI002) --> This is valid SDI001 OR ...
1
vote
1answer
115 views

Regex Pattern to find blank space

This is a single field value and has to be split based on blank lines. Eg: abc street xyz city 785263 lmn street abc city 462738 I tried AddressList = addresses.split('\n{2}') but dose not ...
2
votes
1answer
41 views

Using String.replaceAll() to remove character combination

I need to remove all redundant hyphens in a given string, e.g.: "Bla----Bla---Bla--Bla" to "Bla-Bla-Bla-Bla", using as little code as possible. At the moment I've implemented this: ...
0
votes
1answer
49 views

Problem with processing newLine with Regex in Apex

I'm trying to apply REgex on a Field of type Rich Text Area, Here I'm facing issue with identifying a pattern which is separated with a new line. Rich Text Area value- Some Order Info Order Number ...
1
vote
0answers
58 views

Using RegEx with replaceAll

I'm working on a class that will take the title of an article and post in the URL field. The class itself copies the field and removes characters such as '@' or '/' and replaces it with '-'. ...
0
votes
0answers
25 views

trim the regex validation after third decimal point

I am trying to ignore the values after third decimal point. 7.9.1.73 => 7.9.1 (Remove/Ignore values after third decimal point) Below is my code, but the code doesnt do the trim and give null ...
0
votes
1answer
70 views

RegEx expression in Lightning Component seen issue even if its works in RegEx tool

Trying my hands on RegExp in lightning component.The regExp i've validated using https://regex101.com/ is working fine but fails to work in controller.js. Pls advice if am missing on anything. ...
0
votes
1answer
49 views

Return all groups in RegExMatch Ampscript [duplicate]

I have "some" generic string with some digits and others chars. I need to remove everything that is not a digit from it. 'a222. / --0011' -> '2220011' I think this is a job to be done ...
1
vote
1answer
118 views

SSJS RegExp.exec() works different - why?

Once again, I try to understand why SSJS in SFMC is acting differently compared to JS. Based on the following sample: RegExp.prototype.exec() SSJS Example: <script runat=server> var str = '...
0
votes
1answer
34 views

Find all non-alpha characters in string (excluding special alpha chars) and capitalise each word before/after the character

I'm looking to capitalise each part of a string that precedes/follows a special character and found this post which does the trick nicely. Only problem is it also sees characters which are special ...
0
votes
1answer
408 views

Validation Rule for Currency field with Max 2 decimal places

I am trying to create a validation rule for currency field which will take the maximum 2 decimal places only if you put the third decimal value it will should give you an error. My currency field is ...
0
votes
1answer
85 views

Regular expression is not working as expected in apex

I'm working on design patterns while I'm testing in the anonymous window it's working as expected. But when i trying to implement the same logic it's unable to find matches My expression:'^([0-9])\\1*$...
1
vote
0answers
35 views

REGEX With bind variable inside flow screen not working

i'm doing a field validation inside a flow screen with the regex formula field: !REGEX({!CustomerNumberList}, **{!Account_Customer_Number}**) And it seems the second argument is not being binded by ...
1
vote
2answers
300 views

Regex matching multiple words from the LIST [closed]

Writing Regex that matches the set item list? for an example, write regex that matches whatever is in the targetValues ? Apex code: String result = 'favorable day can one introduced two sentiments ...
0
votes
2answers
136 views

Validation rule to verify if at least two digits in a string

I would like to set up a validation rule to check that there is at least two digits in the string. in Python I would go with this NOT(REGEX(Field_Name__c, "(?=^(?:\D*\d\D*){2,}$)")) But Salesforce ...
0
votes
1answer
22 views

relpace a substring if it matches a particular format?

In my app, i get a list of strings as a response to the http request. In those strings, some strings may contain a html tag at the beginning. The format of the string is like this <span class="qtO"&...
0
votes
2answers
303 views

Apex regex pattern to match Space hyphen Integer

I have the following values for a custom picklist field Lower - L1 Upper - L2 Side - L3 What is the regex pattern to match the above values? Mainly this pattern {anylength of string}{one ...
0
votes
2answers
778 views

Regex for phone number field in Flow screen input validation doesn't return any error

I've the following working REGEX code set as validation rule when we create an account. I've create a Flow and set this REGEX as pattern into a phone number field in Flow screen input validation and ...
0
votes
1answer
44 views

Not able to replace DoubleQuote from a specific Javascript String in Aura Helper component using Regular Expression

I want to replace DoubleQuote from a specific JavaScript String in Aura Helper component using Regular Expression. My JS String is ab ","{ cd I want it to be ab ,{ cd I am performing this operation:...
1
vote
1answer
59 views

Visual Flow- REGEX to check only one occurence of a word in a visual flow collection variable

I want to build a Regex to check only one occurrence of a keyword ".com" in a collection variable "collectprimaryURL" It should be occurred only one time in the variable. I'm using a Regex : REGEX({!...
0
votes
1answer
64 views

Remove ASCII signs - problem with regexmatch function in AMPScript

I'm trying to remove from the beginning and end of the word the \x00-\x20 signs. I don't know what is not working when I'm applying the code I'm not receiving any result. Any thoughts? SET @regex = ...
0
votes
0answers
295 views

Error escaping double quotes in large JSON string in Apex

I have large JSON response that I am trying to escape all instances of strings that are problematic for deserialization but am having some issues. Using .replaceAll works but that throws a "Regex too ...
0
votes
0answers
29 views

Regex to replace visualforce line only if not commented

I am trying to determine if the markup of a visualforce page contains a line of code and only if it is not commented out then replace it. I was hoping to do a simple string.replace with the regex ...
0
votes
1answer
67 views

Can you use Regular Expression to Conditionally display an Image Element in a Screen Flow?

I'm working on a screen flow for collecting payment information. I am currently validating card info based on the digits using REGEX, and would like to use the same formula to conditionally display a ...
0
votes
1answer
109 views

Regex validation for birthdate in the format of mm/dd

I have a custom text field with a max length of 5 characters and I'm trying to use regex to enforce a date entered in the format of mm/dd. Two digits, then a "/", followed by two digits. I was trying ...
0
votes
1answer
958 views

How to do regex for Iban internationally

I found a regex example for international iban numbers but the is returning false. What am I doing wrong. Apex public static Boolean validateIban(String iban) { Boolean res = true; ...
0
votes
1answer
35 views

Looking to generate a regex pattern for matching strings between backslashes

I'm looking to create an HL7 (type of message) parser. Part of that is being able to grab hex values which will appear as follows, with xxyy as single-byte hex values, xxyyzz as multi-byte hex values ...
0
votes
2answers
3k views

Regex for string but at least one character must be a number or letter [closed]

I have a lightning input component and I need the input values to be only alphanumeric characters, underscores and/or spaces. However, there is also one more requirement to have at least one number or ...

1
2 3 4 5 6