Find and Replace Regex Pattern Change RGB

I am allowing users to add values into my database using the Rich Text Editor plugin built by Bubble. I need to provide certain functions for formatting through the RTE, however, I do not want my users to change the colors of the text. It is not possible with the RTE to select with formatting options to make available (can only do the 3 choices basic/medium/full).

In trying to mitigate these issues I am wanting to run a find and replace function on the dynamic values to change any colors to fonts the user might have added to the font color I want it displayed in.

I don’t know how to make it so I can look for multiple possible RGB values, or how to make it find any unknown RGB values and replace with the one RGB value it should be displayed as.

Screen Shot 2022-02-04 at 1.08.34 PM

I would like to be able to use a regex pattern to basically say find any rgb of any value combination without needing to hardcode the different rgb values they may have selected in the RTE.

Any regex pattern that could do this?

@boston85719 try using this regex pattern rgb\(\d+,\d+,\d+\) But if you want to take into consideration the possibility of the user adding spaces before and after the commas, you can use this, rgb\(\d+\s?,\s?\d+\s?,\s?\d+\)

1 Like

This works great when adjusting values that a user may have altered when using the Bubble built Rich Text Editor plugin.

Thank you!

Any idea what I would need to do to adjust it so that I could target when it is font color versus highlight color?

[color=rgb(102, 185, 102)]
[highlight=rgb(0, 138, 0)]

I tried to add [color=rgb\(\d+\s?,\s?\d+\s?,\s?\d+\)] into the regex pattern but I get strange results.

@boston85719, change it to \[color=rgb\(\d+\s?,\s?\d+\s?,\s?\d+\)\] and

Thank you!

Got this put together to remove any color chosen and replace with my apps font color and for highlights to just remove and make transparent.
Screen Shot 2022-02-05 at 11.23.42 PM

Screen Shot 2022-02-05 at 11.23.28 PM

1 Like

How to do the same for images, for example, I want to change any image with any width to a certain width:

[img width=1000] to [img width=100%]


Hey guys,

I’m also wondering how to apply this to images within RichTextEditor…

How can we remove images to only show text? (this is important for forms with limited space where we just want to show a headliner of the content with a read more button)

Best regards,