How to use string-regex?


I wanted to try the new module string-regexp module.
I’m using the ESP32 WROVER platform on the simulator.

I’ve added the module dependency in my module.ivy.
When I try to access the new methods I can’t seem to use them.

  • Eclipse does not provide completion for the new methods.
  • Trying to use them regardless of the compilation error leads to Exception in thread "main" java.lang.Error: Unresolved compilation problem:

Here is the snippet of code I tried:

		String s = "asdf";
		System.out.println(String.replaceFirst(s, "[:alpha:]", "X"));

I looked into com.microej.stringregex.StringRegexExtension to find the added method.
Can you tell me what I did wrong?

Thank you.

Hello @medhi.j ,

The newly added string-regexp module is a new kind of extension module for our libraries which requires some extra steps for them to be used that are still being actively developed and documented on our side. So for the moment there isn’t actually any way for developers to use them, but we hope to make the complete feature available soon and communicate about it.
In the meantime, if you are interested in a regular expression processing feature, we can suggest trying the new jakarta-regexp module which can be used as usual like all our other libraries.

Hope that helped clarifying this issue for you.

Best Regards,

1 Like

Hello once more,

To add to my previous reply, while there is no available way for now to use the Extension modules methods with String as you are trying to do in your example, you can still use the methods from the module by themselves, by giving the String you would want to call the method from as the first argument. With your example, that would give :

String s = "asdf";
System.out.println(StringRegexExtension.replaceFirst(s, "[:alpha:]", "X"));

This way, you can still use the method as you would with a usual MicroEJ library module.

Hope that helps.

Best regards,