Regex help, only dependent on first letter

hi, i have a problem using the regex utility,
i have an array containing random words.
i need to filter out and print out the words that starts with a, h or m.
this is part of my coding
it seems to me that the comparison will print any word with a, h or m instead words that start with the letters.
Arrays.sort(b);
Pattern p = Pattern.compile("ba", Pattern.CASE_INSENSITIVE);
               while(last<w)
                    String comp = new String();
                    comp = b[last].toString();
                    Matcher m = p.matcher(comp);
                         if(!m.find())
                         last++;
                         else
                         System.out.print(comp);
                         System.out.print(" ");
                         last++;

i have to apologise, i'm still new and it's my first post.
pls forgive me.. anyway i got the problem solved.
i need to only compile the following pattern ("^a|^h|^m")
and voila~!
: )

Similar Messages

  • LDAP Addressbook search - match first letter only

    According to the SPA500 Admin Guide, a LDAP query will search on every letter:
    "This searches for the text string anywhere in the beginning, middle, or at the end of a name."
    Would it be possible to search only on the first letter of a name?
    Erik

    Eric, I don't know if you ever solved this request.
    In the search syntax you will see the "$VALUE" criteria bounded by two "*". These serve as wildcard matches. If you simply delete the first "*" before $VALUE your match will start at the beginning. Likewise if you remove the second "*" instead the search will try to match at the end. If you remove both it will look for an exact match.
    John

  • Pricing or Tax Based on First letter of Batch

    Hi Guru
    I have a requirement  Tax or price  should be charged based on Batch  where batch starts with 'R' .
    then system has to charge  on that Batch  only  7 % Percent Tax or price.
    Could you please help how  to consider first letter of the Batch for tax or price determination.
    Thanks in Advance.

    Hi Rakare
    This can be achieve with the help of ABAPer. Go to VOFM and write a calculation formula as per your requirement. Assign the calculation formula to your tax and price in pricing procedure.
    goto VOFM>Formulas>Condition value.

  • First letter on a line only partially printing

    HP 3310 Photosmart All-in-one
    On almost every page printed, the left-most part of the first letter on (mainly) the first line of the page does not print.  Frequently, first letters on subsequent lines (not necessarily consecutive)  also only partially print.  Sometimes, interior letters have the same problem.
    I have changed cartridges several times and cleaned print heads several times (although the test sheet printed when cleaning printheads is invariably perfect). Sometimes the very lowest portion of several letters in a row will not print.  
    The problem happens with different paper stock, different fonts, and different cartridges (including genuine HP cartridges.  

    RichardK wrote:
    HP 3310 Photosmart All-in-one
    On almost every page printed, the left-most part of the first letter on (mainly) the first line of the page does not print.  Frequently, first letters on subsequent lines (not necessarily consecutive)  also only partially print.  Sometimes, interior letters have the same problem.
    I have changed cartridges several times and cleaned print heads several times (although the test sheet printed when cleaning printheads is invariably perfect). Sometimes the very lowest portion of several letters in a row will not print.  
    The problem happens with different paper stock, different fonts, and different cartridges (including genuine HP cartridges.  
    It sounds like you have an issue with the ink drying out in the printheads.  This could be caused by a defective service station area (the part that caps the printheads while not printing), bad ink or by turning the power off to the printer before the printheads have been put away properly.
    It would take a long time for a change of ink cartridges to actually show up at the printheads, there would be a significant amount of ink that remains in the system even after a cartridge change.  You say you have used different cartridges (including genuine HP cartridges).  Does that mean you have used non-HP ink?   I would suggest putting in HP ink and running several (three or more) cleaning cycles but unfortunately if you have used bad ink it may be very difficult to flush this out of the system.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Change only first letter to uppercase

    Hello,
    Have a way in graphical mapping to change only the first letter to uppercase?
    Elad

    hi,
    Please do the following mapping. hope this will help you.
    input-->SUBSTRING1>uppercase-->Firstinput to concate function
                                                                    CONCATE----
    >output
                      input-->SUBSTRING2--->second input to concatefunction
    Set Substring1: starting position=0 and numberof chareters =1
    set Substring2 :starting position=1 and numberof chareters =0
    regards
    Kasturika

  • My MacBook pro mid 2012 doesn't seem to have a "save as" function, so I can't seem to save multiple page pdf's together after moving thumbnails into the sidebar. It only saves the first page. I can't figure out the rename function either. Help?

    My MacBook pro mid 2012 doesn't seem to have a "save as" function, so I can't seem to save multiple page pdf's together after moving thumbnails into the sidebar. It only saves the first page.
    I do have a 2008 version of Microsoft Office installed to save money, but that shouldn't affect things. I can't figure out the "rename" function either. Help?

    Oh, and I also reset my NVRAM, my computer hasn't frozen again yet, so I'm not sure if it has made a difference.

  • I'm trying to print out a credit card statement from my iPad, it only prints the first page not 4pages, please help

    I'm trying to print out a credit card statement from my iPad, it only prints the first page not the 4 pages, please help

    I read your first post when I was posing a separate question on the Mac Pro board.  I now see that we may be talking about printing from an iPad with Airprint instead!!!!!  I very much suspect the print command and settings are different for Airprint but I have never used it to be able to offer concrete advice.  I think the setting choices could be different even with Airprint on the laptop and further that you may not even be using Safari but some special app???
    I've not heard or seen the term "frame" in the context of printing before except perhaps in the context of a screen shot.  Is the credit card statement a "pop-up" of some kind rather than a webpage or pdf?

  • Right or Wrong? help: user account short name has Capital First Letter

    Hello
    I have the same issue as a post in the Mountain Lion discussion group.  It doesn't seem to be getting an answer.  So I thought I would post it here, being that I do have Snow Leopard.
    The Mountain Lion post is here: https://discussions.apple.com/message/21665861#21665861
    Here is MY question::
    Can anyone answer this?  I have this same thing.  I've had this Mac since 2010, too, I think, at least two years.  I don't remember being asked to use lowercase, nor actually typing in the Capital letter.  I stumbled upon the realization when I was using my Macbook and my user name whille different does use all lowercase.  The Macbook is newer.
    I've been running this Mac with the first letter Capital for the short name with no problems that I know of.  I do have Time Machine backups that I don't really want to lose access to.
    What are the benefits and pitfalls of using the method etresoft explains to change it to all lowercase??  Should I do it just to do it and be in line with Apple's guidelines or should I leave well enough alone??  Which way will cause me MORE problems?  Running with the Capital letter or going through the process of changing it to lowercase??
    What kind of problems will I run into if I change it or don't change it???
    Where "oldshortname" is your old user name and "newshortname" is the user name you want to change it to. Keep in mind that both oldshortname and newshortname must be all lowercase, with no spaces, and only contain letters or numbers.
    And, Padgreen has an excellent point -- how do we do this change process if our Old Shortname is Shortname??  How can we type "shortname" for the "oldshortname" if our shortname is not all lowercase??
    etresoft -- are you around??
    Or someone else?  Thanks!!
    (the only thing I can even think of as a problem is when I copy files/folders over to my Macbook - it sometimes makes "nobody" the owner of the file/folder and I find out when I try to edit or move the file. I can usually just change the owner and everything is fine.  I don't know if this is related or not.)

    http://support.apple.com/kb/ht1428 states:
    Select the Home folder with the short name you want to change, and rename it just like you would rename any folder. Keep in mind that the shortname must be all lowercase, with no spaces, and only contain letters.

  • Regex: searches for first letter in word return all letters

    I want to init-cap the words in a sentence, and I use the pattern "\\b[a-z]" to search for the first letter of each word. However, it actually matches all the letters, so that the entire sentence is capitalized. If I reverse the pattern to look for the last letter of each word, "[a-z]\\b", then only the last letter is capitalized as expected.
    Is this a bug or a misunderstanding of regular expressions on my part?
    Here's my code:
    String s = "this is a test";
    Pattern p = Pattern.compile("\\b[a-z]");
    Matcher m = p.matcher(s);
    StringBuffer sb = new StringBuffer();
    boolean result = m.find();
    while(result) {
    m.appendReplacement(sb, m.group().toUpperCase());
    result = m.find();
    m.appendTail(sb);
    System.out.println(sb.toString());

    It capitalizes only the first letter of words for me. Try getting the latest version of the JDK.

  • HT1692 I am not able to scroll my contacts. If i add or mahe any change in existing contacts, it appaers at the top of the contacts and freezes rest above the first letter of newly added or changed one. Anyone can help?

    I am not able to scroll my contacts. If i add or mahe any change in existing contacts, it appaers at the top of the contacts and freezes rest above the first letter of newly added or changed one. Anyone can help?

    Hi,
    >>1. how can i align Title(DCS Clinical Report-Technician wise) center of pdf report with image named:logo5.png immediately coming to it's right?.
    2. how do i add the given below row and it's data to my top my table in pdf report from c# windows forms using itextsharp?
    3.how to make my column headers in bold?<<
    I’m sorry for the issue that you are hitting now.
    This itextsharp is third party control, for this issue, I recommended to consult the control provider directly, I think they can give more precise troubleshooting.
    http://sourceforge.net/projects/itextsharp/
    Thanks for your understanding.
    Regards,
    Marvin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • My ipad keypad make a loud snap noise when I start to type. It's not the regular click sound it sounds like an electric snap and it just started to happen. It only snaps when I type the first letter

    My ipad keypad makes a loud snap noise when I start to type. It's not the regular click sound it sounds like an electric snap and it just started to happen. It only snaps when I type the first letter
    Ipad only about 2 months old. 64gb cellular
    Has anyone had this problem?

    in the future, buy this, this is what the Pros use:
    for drops, accidents, spills, loss, or theft, purchase a TYPE of insurance called "inland marine insurance"
    roughly $30 per year for a device(s) with 0 deductible, used same for over 20 years, same insurance the pros use on their portable devices.
    very cheap, very useful insurance, most people dont know about same.
    http://en.wikipedia.org/wiki/Inland_marine_insurance

  • I am have problems loading a cd onto i-tunes. No matter how many times I try to load a particular cd it will only load the first 9 seconds of each track. Can anyone help?

    Can any one help? I have tried several times to import a particular cd onto i-tunes, but each time it will only load the first 9 seconds of each track.

    If it was a recent purchase you could take it back to the store and return it as "not fit for purpose", then buy a digital version. If it is too late for that I suppose you could try contacting the record company but I doubt they care at this point since they have the money. Can't really go into any possible workarounds without breaching the TOU.
    tt2

  • How to split words in two arrays depending of the first letter.

    Yes, how to split words in two arrays depending of the first letter.
    I have a string array with some words, and I need to separe this array into two differents string arrays depending of the first letter:
    if the word starts in A to M the word goes to array Words_AM;
    if the word starts in N to Z the word goes to array Words_NZ;
    Now I'm doing the next:
    if ((ArrayWord.charAt(0))<='a') && (ArrayWord.charAt(0)>='m'))                                        {                                                                                          
    Words_AM]=ArrayWord;
    else
    Words_NZ[i]]=ArrayWord;
    But doesn't work.
    Any solution?
    Best wishes.

    Yes , that's true. But also I have to change the <='a' to <'a', because of with first option didn't selecting the a letter.
    But with z letter, doing the same before, doens't run.
    if ((ArrayWord.charAt(0))<'a') || (ArrayWord.charAt(0)>='m'))
       Words_NZ]=ArrayWord;
    else
    if ((ArrayWord.charAt(0))<='n') || (ArrayWord.charAt(0)>'z')) Words_AM[i]]=ArrayWord;
    Regards ;)

  • Help!  iTunes only imports the first 3 seconds !!

    When i insert a CD and select import the software only imports the first few seconds argghhh !

    Jimmy, What happens when you rip the same CD with a different program on the same computer, such as Windows Media Player?

  • Regex and matcher only returns the first match

    Hi all.
    Im trying to rewrite some code and im using a regular expression to grab data out of a css formatted file, but im getting a bit confused. My matcher is only finding the first occurance of my pattern, how do i get it to find all occurances of my pattern?
    here is a sample css file
    .header
    font-family:arial, verdana;
    font-weight:bold;
    color:#ff00ff;
    background-image:url(background.jpg);
    .mainBody
    font-weight: bold;
    color: Red;
    padding 0px;
    }and here is my matcher code
    tstr = tstr.replaceAll("\\\\","/");
    tstr = tstr.replaceAll("\\n","");
    tstr = tstr.replaceAll("\\r","");
    Pattern styleFind=Pattern.compile("^\\.?[\\w\\s\\W]+?\\{.*?\\}",Pattern.DOTALL | Pattern.MULTILINE);
    Matcher styleMatch=styleFind.matcher(tstr);
    while(styleMatch.find())
    System.out.println("[A]"+styleMatch.group());
    }     i thought that if i did while(macther.find) then it would keep looping through finding all of the matches, but it is only finding the first match.
    any ideas what im doing wrong?

    tstr = tstr.replaceAll("\\\\","/");
    tstr = tstr.replaceAll("\\n","");
    tstr = tstr.replaceAll("\\r","");
    Pattern
    styleFind=Pattern.compile("^\\.?[\\w\\s\\W]+?\\{.*?\\}", Pattern.DOTALL | Pattern.MULTILINE);
    Matcher styleMatch=styleFind.matcher(tstr); You do MULTILINE despite the fact that you delete all end of line characters first. The '^' matches only at the very beginning of the input.
    Apart from that I would prefer "[^\\}]" anytime ofer ".*?\\}", because what you want is a shortest match which often turns out not to be the same as a non-greedy match.
    Harald.
    Java Text Crunching: http://www.ebi.ac.uk/Rebholz-srv/whatizit/software

Maybe you are looking for

  • Can not update creative cloud

    Can not update creative cloud, it keeps saying "Installer was unable to access a critical file/directory. Please try installing again.(Error code: 43) Contact Customer Support". Any ideas?

  • Blank report for CSV format

    Hi, I need help me to generate a report in csv format. I am using .rtf template and able to view HTML, PDF etc.. But for .csv format the report is blank. Below is how my csv output should look, If possible please give a sample .rtf template or etext

  • BW reporting for cFolders

    Hi, Anyone has done the BW Reporting for cFolders? We are in ECC6 with SAP cFolders 4.5. This is what i have done in BW for cFolders, but the query part don't show anything. - Went to RSA5 and Activate Datasources under APCO_CFOLDERS. The following d

  • Error on iPad mini

    I am getting the following error on my iPad mini and would like to know how to resolve it: Microsoft OLE DB Provider for ODBC Drivers error '80004005'  Specified driver could not be loaded due to system error 126 (MySQL ODBC 3.51 Driver).  /asp/month

  • Trouble with Preview function- thumbnails

    Adobe photoshop elements 9:  Problem occurs after downloading my images from my camera's memory card.  I have all the thumbnails open & have always right clicked on an individual photo, hit preview & viewed my photos as a slideshow to copy, delete, e