String.matches - Regular Expression

194 views
Skip to first unread message

paulac...@gmail.com

unread,
Feb 28, 2013, 2:25:15 PM2/28/13
to codenameone...@googlegroups.com
Hi, I've building a Android app in which I have to validate some textFields' contents.
I've tried to use String.Matches, but it seems that Android don't support it. How could I validate this data?

Thanks in advance.

Shai Almog

unread,
Mar 1, 2013, 1:08:52 AM3/1/13
to codenameone...@googlegroups.com, paulac...@gmail.com
Hi,
we don't support regex at the moment and some of the more elaborate string methods (e.g. matches, split etc.). This is planned for the future but isn't there yet.
At the moment you will need to write the logic in Java rather than use a regex e.g. indexOf(x) to verify the existence of a char.

Alternatively you can incorporate one of the open source regex implementations from the web.

Steve Hannah

unread,
Mar 1, 2013, 1:30:03 AM3/1/13
to codenameone...@googlegroups.com, paulac...@gmail.com
If you're using a platform that has a native browser component (i.e.
Android or iOS) you can also use Javascript for regex via the
BrowserComponent.executeAndReturnString() method.

-Steve
> --
> --
> You received this message because you are subscribed to the Google
> Groups "CodenameOne Discussions" group.
>
> For more information about Codename One please visit
> http://www.codenameone.com/
>
> To post to this group, send email to
> codenameone...@googlegroups.com
> To unsubscribe from this group, send email to
> codenameone-discu...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/codenameone-discussions?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CodenameOne Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to codenameone-discu...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Steve Hannah
Web Lite Solutions Corp.

Paula Ceccon

unread,
Mar 4, 2013, 3:55:45 PM3/4/13
to Steve Hannah, codenameone...@googlegroups.com
I'm trying to check my expression with charAt.
So, I get the character at the index that I want.
But in some points I have to convert it to int, to check if its a number.
So, I tried to do this:

Integer.parseInt(Character.toString(text.charAt(i)));

But it seems that I also cant't use Character.toString. I have to check all possibilities in Codename One??

Thanks, again. (:
--
Paula Ceccon Ribeiro
Master Candidate in Computer Graphics
PUC-Rio



Steve Hannah

unread,
Mar 4, 2013, 3:58:11 PM3/4/13
to Paula Ceccon, codenameone...@googlegroups.com
Just go by the CodenameOne API docs:
https://codenameone.googlecode.com/svn/trunk/CodenameOne/javadoc/java/lang/Character.html

Notice that there is no static toString() method in the Character class.

-Steve

Paula Ceccon

unread,
Mar 4, 2013, 4:08:09 PM3/4/13
to Steve Hannah, Shai Almog, codenameone...@googlegroups.com
Yeah, you are completely right. Sorry for the dumb question.
Reply all
Reply to author
Forward
0 new messages