+ Start a Discussion
Revathi V 18Revathi V 18 

Regex in workflow to remove line breaks and white spaces

I'm trying to remove line breaks and white spaces in Rich Text Area field when Text Area is not containing any words or characters.I'm doing this by using workflow.I used "^[\\s<>br]+$"  regex,but this is not satisfield in Rule criteria.
Any one can suggest the correct regex to do this?

Thanks in advance
sachin kadian 5sachin kadian 5
This worked for me
 
REGEX('fieldName', '^\\s*$')

 
sachin kadian 5sachin kadian 5
User-added image
Revathi V 18Revathi V 18
Thanks for your reply..but this is not working for me.
sachin kadian 5sachin kadian 5
can you provide screenshot how are you doing this? is your workflow activated?
Revathi V 18Revathi V 18
User-added image
sachin kadian 5sachin kadian 5
So what are you getting after editing the record with with whitespace and line breaks?
Revathi V 18Revathi V 18
This is field update

Rich Text Area(SHI__c) field is not updating after editing the record.It's showing that whatever spaces and lines i gave.
kamala swarnalathakamala swarnalatha
Hi Revathi,

Can you please explain the requirement briefly?


Thanks,
Kamala
Sweet Potato Tec.
Revathi V 18Revathi V 18
I have one Rich Text Area field.If this field contains any word or character with line breaks and spaces,i want to show as it is.
If this field contains only line breaks and spaces,i just want to nullify the field because it's taking too much space on the UI.
kamala swarnalathakamala swarnalatha
Hi,

I have worked on this issue it never consider the Line break in the Rich Text Area field because when we pressed enter button it consider as the paragraph not a line so it doesn't check the line break.

It checks the white spaces using the  formula
REGEX('fieldName', '^\\s*$')

See the link to Know the properties of the Rich Text Area field 

https://help.salesforce.com/articleView?id=fields_using_rich_text_area.htm&type=5

Hope this helps!
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.


Thanks,
Kamala
Sweet Potato Tec.
 
Revathi V 18Revathi V 18
I gone through the link which you provided. They have mentioned that it will consider as paragraph if we press enter key only in Lightning Experience and salesforce app but am using salesforce classic.
Paragraphs
Pressing the Enter key creates a paragraph, which adds padding to the text when saved in Lightning Experience and the Salesforce app.