java - Regex is getting other words -


I am using regex in java, I want to get the upper case of only one string.

Example:

  1.- M / PS (Obstatic) - Group 1: M group 2: PS 2.- M / PS * - Obstetrico - Group 1: M Group 2: PS3- H / PS Adulo - Group 1: M Group 2: PS  

Now when I use:

  regex : ([AZ] +)  

For the first case: group1: m group2: PS group3: O < / P>

So I say that I'm going to leave this method:

  regex: ([AZ] + [^ az])  

  • PS *
  • I will use Test: Input H / M * H (Syquitria) PS * M / PS Infantil H / M / PS M / PS (Obstetrico)

    OPT H, MH PS M

    If you enter ([AZ] +) [^ Az] You will find for each string:

    Group 1: M

    Then after the next search () you will meet again

    Group 1: PS

    Explanation; In any group, the regex is captured in one of the z axis in any order, which is followed by something that is not for z. Thus, it will first occupy M in the group, then start searching again and capture the PS in the first group.


    Especially for your 3 string, you can use ([AZ]) * / * ([AZ] +) Group 2: PS

    Explanation: regex a Z from a single letter which is a place 0 or more often, Followed by a slash (/), followed by a location 0 or more often, after captured one sequence of Z characters. In this way it will move the M group to the first group, proceed through the possible location and slash, and capture the PS in the second group.


    Comments

    Popular posts from this blog

    Editing Python Class in Shell and SQLAlchemy -

    import - Python ImportError: No module named wmi -

    uislider - In a MATLAB GUI, how does one implement a continuously varying slider from a GUIDE created .m file? -