Java regular expression matching for CSS double class attribute -


I have to put a boolean that tells me that a CSS selector is either:

  • ID selector (#) + class selector (.) In the same element, like table # some edit. Some class
  • class selector (.) + ID selector (#) in the same element, such as Table.someclass # someid
  • In the same element, double class selector (.), Such as table .class1.class2

The substrings are matched in a selector, in which the connectors like Table> tr # someid.someclass> td ...

this is my code :

  import java.util.Scanner; Import java.util.regex.Matcher; Import java.util.regex.Pattern; Public Class Multiple Class ID {Private Static Final String Reggae [=] (# [^ \\ s \\ + & gt; ~ \\. \\ [:] +) (\\. [^ \ \ S \ \ + + And gt; ~ \\. \\ [:] + "", "(\\. [^ \\ s \\ + & gt; ~ \\. \\ [:] +) (# [^ \ \ S \\ + & Gt; ~ \\. \\ [:] + "", "(\\. [^ \\ s \\ + & gt; ~ \\. \\ [:] +) (\ \. ^ ^ [^ \\ s \\ + & gt; ~ \\. \\ [:] +} "}; Public Boolean HMtlSpaceId (string selector) {for (int i = 0; i & lt; regexs.length ; I ++) {Patterns P = Pattern.com com (Reggae [ii]); Matter M = P. Mettter (Selector); if (m.find ()) is true;} The details are false;} Public place And zero main (string [] args) {scanner input = new scanner (System.in); System.out.println ("select selector:"); string selector = input.next (); Multiple class idid specification cluster = new Multiple ClassID (); Boolean Hamodel = Specification Clocketer. Simultaneous Class ID (Selector); Println (isMultiple);}} There are many specialty selectors in the first element of the selector, such as "tr # someid .someclass ", and for any case listed above. However, if I have a selector like "table tract # someday. Some class", then it gives wrong.  

However, in Regex Planet, it matches it exactly (see the following link).

Is this a problem with my Java Library version? Or is there something wrong with my code? Thanks!

The problem is only

  string selector = input.  

It has to be changed with

  string selector = input. Nxtline ();  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -