Find pattern in string?

Is there a way to find a pattern in a string in blueprints?

for instance I have some names formatted something like “eyeLeftScale”, e.g. the name of the affected item is all lowercase and what it does to said item is described starting from the first uppercase character.

Is there a way I could extract just the ‘eye’ part from this string in blueprints?

The only thing i can think of is find substring, but it doesn’t seem to support regex or wildcards.
24-08-61

So for instance if I could somehow put “first uppercase letter” into substring, then subtract the result by one, i would be able to use get substring to print the snippet I need.

Nothing in-built for regex (or any advanced string manip really). Which is something that has also made me sad in the recent past.

I had been meaning to have a look around, which your post has prompted me to actually do, and I did find this (free) plugin:
https://www.unrealengine.com/marketplace/en-US/product/low-entry-extended-standard-library

Which includes Regex Get Matches and Regex Replace nodes you may be interested in :slight_smile:

I haven’t tried it out yet myself, but judging by the reviews I’m guessing it probably works fine.

1 Like

That looks disgustingly useful but I’ve figured out a way to do what I need without a plugin. A disgustingly inefficient way so I’ll probably end up using that plugin anyways though :laughing: I’m pretty sure the plugin with proper pattern matching is superior.

I have used the get character as number node:
24-08-63

It gets the ASCII decmial value of a character, so using that I can get the range of uppercase characters using an ASCII table like this:

With the downside being that non-english characters aren’t supported (some are but you need to support them on character by character basis, it won’t be a range anymore)

So to print eye like in my original question, I do this:

I’m checking each individual character until I find an uppercase one, when I do I print everything that came before it.

After a bit of consideration though, I’m marking silnarm’s answer as the solution.

Unreal doesn’t have any proper pattern matching functions in it.

1 Like

That’s a neat BP solution, even if not super versatile (the localisation stuff).

Should be subtracting one from that LEN though :wink:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.