Search code examples
javaalphanumericnon-alphanumeric

Print only valid Alphanumeric Strings


Print only valid Alphanumeric Strings

For example, the geral print is:

   Xô3†kЀ?ë±3!æq¥b.    
   Parabéns, conseguiu. 
   ñoÛD¦Ó¶Y˜…Û¬œ«÷ôQÂ.  
   Ãý™448($vúiP±ÔÅã.    
   ÝÆû4sÊìÏiÁLy[r¥…X°.

But i need print only this line:

   Parabéns, conseguiu. 

I try this regex in if operator, but don't work.

   ^([a-zA-Zà-úÀ-Ú0-9]).*$

Solution

  • you have to escape the period with a double backslash as a period on it's own is a wildcard for "any character" as well as allow for one or more a-zA-Z... etc with the +

    ^([a-zA-Zà-úÀ-Ú0-9]+)\\.*$
    

    Not sure if this will work for your implementation. I don't know how those lines are coming in to your regex to begin with.