#Regex for prefix expressions

20 messages ยท Page 1 of 1 (latest)

proud delta
#

Is it possible to identify any valid prefix expression using only a regex?

unique loomBOT
#

Hey, @proud delta!
Please remember to /close this post once your question has been answered!

proud delta
#
(^[\+\*\/\-])\s[0-9]\s[0-9]```This works for ```+ 5 5``` but I need a regex that can extend to n length
#

This covers any thing that starts with a valid operator java ^(\+\s)+|^(\*\s)+|^(\/\s)+|^(\-\s)+ so it covers ```java



/ / /

#

so it looks like it could start with java ^(\+\s)+|^(\*\s)+|^(\/\s)+|^(\-\s)+ and end with java [0-9]$|[a-z]$|[A-Z]$|[0-9]\s+$|[a-z]\s+$|[A-Z]\s+$ the middle is where it gets complex

teal halo
#

can you provide some examples?

proud delta
#

infix is normal 5 +5 = 10 type of math

#

prefix would be + 5 5

#

I almost have it, need to figure out this middle

#

here is what would be needed for the spacing in the middle of the equation java (?<=[a-zA-Z0-9])\s

#

I need a means of asserting that this squared off portion is true

snow meadow
#

What are you doing? It's like you think regex is magic or something

#

What do you mean the end and the middle? How is it different?

proud delta
#

so because im working with something you don't understand... im the one who thinks Im working with magic. Your help is not needed ๐Ÿ™‚

snow meadow
#

Dude... ^(+\s)+|^(*\s)+|^(/\s)+|^(-\s)+

#

Yes you're the one working with magic

#

But I guess I don't understand whether you want to support + + + 5 5 5 5 but not + - / 5 5 5 5

proud delta