Search/replace in bitmap text object?

I’m trying to search bitmap text objects for a forward slash and replace it with a line return using javascript (because I cannot find a way to do a replace without going into js)

I tried this and it worked with regular text objects, but not with the bitmap text objects:

var textObject = runtimeScene.getObjects("plain")[0];
var currentText = textObject.getString();
var updatedText = currentText.replace(/\//g, "\n");
textObject.setString(updatedText);

so i tried this without luck:

var p1Text = runtimeScene.getObjects("p1bm")[0].getRawString();
p1Text = p1Text.replace(/\//g, "\n");
runtimeScene.getObjects("p1bm")[0].setRawString(p1Text);

Is there a special way to do a text search/replace in Bitmap Text objects?

I think you need getText() and setText() instead of the get/set string.

There’s also an extension called regular expressions that might help you.

Doing it without JavaScript would require a mix of findStr() and subStr expression(s) maybe inside of a while or using a variable. I’m not at my PC but it wouldn’t be fun to write.

1 Like

That was it! Thanks!

1 Like