0

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
1234567890
Some related info

Regex -

(Order Number)[\\n]([0-9]+)

Expected Result - (Order Number) (1234567890)

This Regex doesnt work when I apply it to the Rich Text Area field directly. But when I created a String with same value in Apex where \n was used for new lines, it works. Can anyone explain this and correct me where am I going wrong?

Thanks

1
  • Hello, check with html inspector. I'm pretty sure, Rich Text uses <br/> for line-breaks. You can JSON.serialize your variable to visualize line breaks
    – ytiq
    Sep 4, 2020 at 10:30

1 Answer 1

0

since you RichText is basically HTML, so it probably uses
for line breaks or wraps your text in <p>/<div>.

So if you want to do some processing in Apex, you'd probably use \r\n and in RichText use HTML inspector to correctly specify the content.

If you're not sure about separator in APEX you can JSON.serialize the string or you can copy the string to https://www.regextester.com/ and play there with it

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .