java - MQTT topic match evaluation -


i'm implementing android application using mqtt (paho). have components have compare subscribed topic includes wildcards acutal topic client has published to.

i don't head around , "rudimentary" regex-skills don't helpt either...

is there utility class in paho/java mqtt see if

"sensor/temperature/+/degree/#/id" (subscribed topic)

is applies to

"senor/temperature/garden/degree/celsius/abovezero/id" (actual topic)?

does know best way that?

thank you!

edit: hi there - think should right

public static boolean comparetopic(final string actualtopic, final string subscribedtopic){     return actualtopic.matches(subscribedtopic.replaceall("\\+", "[^/]+").replaceall("#", ".+")); } 

your solution should work in case of example regular expression

"sensor/temperature/[^/]+/degree/.+/id" 

a website http://www.regexplanet.com/advanced/java/index.html resource cases this.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -