Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A condition (A OR NOT A) can be omited. So symbols can savely been ignored. </p> <pre><code>for (String word : "10 10-10 open-office 10B A10 UCS5000 code DV-3000 300-BR".split (" ")) if (word.matches ("(.*[A-Za-z].*[0-9])|(.*[0-9].*[A-Za-z].*)")) // do something </code></pre> <p>You didn't mention -x4, 4x-, 4-x-, -4-x or -4-x-, I expect them all to match.</p> <p>My expression looks just for something-alpha-something-digits-something, where something might be alpha, digits or symbols, and the opposite: something-alpha-something-digits-something. If something else might occur, like !#$~()[]{} and so on, it would get longer. </p> <p>Tested with scala:</p> <pre><code>scala&gt; for (word &lt;- "10 10-10 open-office 10B A10 UCS5000 code DV-3000 300-BR".split (" ") | if word.matches ("(.*[A-Za-z].*[0-9])|(.*[0-9].*[A-Za-z].*)")) yield word res89: Array[java.lang.String] = Array(10B, A10, UCS5000, DV-3000, 300-BR) </code></pre> <p>Slightly modified to filter matches: </p> <pre><code>String s = "A35, 35A, B53X, 1AC5, AB-10, 10-AB, A10-BA, BA-A10, etc. -4x, 4x- -4-x- 10-10, oe-oe, etc"; Pattern pattern = java.util.regex.Pattern.compile ("\\b([^ ,]*[A-Za-z][^ ,]*[0-9])[^ ,]*|([^ ,]*[0-9][^ ,]*[A-Za-z][^ ,]*)\\b"); matcher = pattern.matcher (s); while (matcher.find ()) { System.out.print (matcher.group () + "|") } </code></pre> <p>But I still have an error, which I don't find: </p> <pre><code>A35|35A|B53X|1AC5|AB-10|10-AB|A10-BA|BA-A10|-4x|4x|-4-x| </code></pre> <p>4x should be 4x-, and -4-x should be -4-x-. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload