Java + Regex (Searching one or more words within quotes)

Hi Everyone,
I have the following text:
The brown "cow" jumped over the "contributor licensing agreement" and went to "Burger King" to order chicken wings.
The text above may change. This is the input text. In the input text, I want to find and print out all phrases that are inbetween quotes. I tried the following:
Pattern pattern = Pattern.compile("\"(.*)\"");
Matcher matcher = pattern.matcher(paragraph);
while(matcher.find()){
    String theMatch=matcher.group();
    System.err.println("Found: "+theMatch);
}The regex expression works in my regex coach program (which helps me test regex on input strings). In the Java code, however, the application only finds "cow", not "contributor licensing agreement" or "Burger King." What do I need to do in order to find those other two phrases? I want to use this to parse out and find all words or phrases in a document that are inbetween quotes.
What am I doing wrong??
jetcat33

how about using a "reluctant" quantifier "?"
    Pattern pattern = Pattern.compile("\".*?\""); // note the question mark
    Matcher matcher = pattern.matcher(paragraph);
    while(matcher.find()){
        String theMatch=matcher.group();
        System.err.println("Found: "+theMatch);
    }

Similar Messages

  • Is there a way to remove one or more words in the dictionary list of auto-completion?

    Is there a way to remove one or more words from the dictionary list of auto-completion?

    Hi Gordon,
    Auto-completion does not involve the dictionary. The process is dynamic, and remembers the text string you have entered into each cell. The auto completion list is constructed using data you have entered into cells above the one you are currently working with. Suggestions presented contain the same character string as a previous entry in that column. Editing the list presented is not possible.
    Auto-Correction does involve the spelling dictionary. It monitors the text as you type. If it finds an 'unregognized word,"' AND has more than one suggestion as to the 'correct' word, it opens a dialogue, giving you a chance to choose one of the suggestions, enter your own corection, or to accept the current spelling. If there is only one suggestion offered, Auto-correction automatically replaces the unrecognized word wth that suggestion.
    Regards,
    Barry

  • Searching for a whole word within a sentence

    I am trying to search for a whole word only in a sentence. The problem is if I use CS then I get things that contain the string in other words. If I use CO or CP then there is no match because there are other words in the sentence. I don't think it's practical to split the sentence into individual words and then compare each word as the sentence is of an unknown length and could be made up of many words.
    An example:
    Sentence 1 - THIS IS ABOUT RF OUTPUTS.
    Sentence 2 - THIS IS ABOUT MY PERFORMANCE
    The user wants to search for sentences containing RF. In this search I only want sentence 1 to be found and not the RF in the word performance in sentence 2.
    Can anyone tell me how to do this.
    Many thanks
    Karen

    DATA: str1(50),
          str2(50),
          srchstr(10).
    DATA: BEGIN OF st_str,
            str(50),
          END OF st_str.
    DATA: it_tab LIKE TABLE OF st_str WITH HEADER LINE.
    str1 = 'THIS IS ABOUT RF OUTPUTS RF'.
    str2 = 'THIS IS ABOUT MY PERFORMANCE RF'.
    srchstr = 'RF'.
    SPLIT str1 AT space INTO TABLE it_tab.
    LOOP AT it_tab WHERE str = srchstr.
      WRITE : srchstr.
      WRITE 'found in'.
      WRITE 'str1'.
      EXIT.
    ENDLOOP.
    CLEAR it_tab[].
    SPLIT str2 AT space INTO TABLE it_tab.
    LOOP AT it_tab WHERE str = srchstr.
      WRITE : srchstr.
      WRITE 'found in'.
      WRITE 'str2'.
      EXIT.
    ENDLOOP.
    Check this code as it solves the leading RF and trailing RF problem .

  • O365 EWS API - search one or more mailboxes for specific email, check if read?

    Howdy All - 
    Can anyone point me as to how you can search a single or multiple mailboxes for a specific email by sender or subject to find out if the email was read?
    I have scoured the net and can not find anything related to this for O365 or even Exchange 2013.
    Thx!
    Domran

    You could use EWS to search mailboxes.
    https://msdn.microsoft.com/EN-US/library/office/dn579422(v=exchg.150).aspx. You can easily check the
    IsRead property on mail items.
    However, I would point out that finding out if a mail is read is somewhat troublesome. How do you know a mail was read? If it is marked read? Users can toggle the read/unread state of a message, so that's kind of unreliable. You can also right-click a folder
    and choose "Mark all as read", without ever actually reading the message. So depending on what you're trying to do, this may not be something you can programmatically determine.

  • Search for more words one time

    Goodmorning, as long someone could help me with the other issue http://forums.adobe.com/thread/1057325?tstart=0 I have another question for you.
    I need to search for a specific list of words but I want to search only one time... So for example if I'm searching 3 different words HELLO - GOODBYE - CIAO I want that acrobat perform the searches in the same time and let me see how many times the words are repeated.
    I try with the advanced search but I can only search one word at time...  I see there is a command under tools>protection>find and remove text (hope I have translate right from Italian software) to search for different words in the same time but the problem is that it can't report how many times thw words are repeated. As you see I need a mix of the two tools
    Do you have some suggestions?
    Hope to read you soon. Thanks,
    Luca
    PS: I know I can do that with the boolean expression but in this way acrobat doesn't separate the rusults.

    It will work with any of the smart album criteria - file menu ==> new smart album
    The easiest way to see is to take a look at what is available there - and make a smart album or two - if you don't like them just drag them to the iPhoto trash and do another one
    LN

  • How do I search for adjacent words within MS WORD?

    I am new to Mac. I need to search WITHIN MS Word Documents for specific phrases. Example: Jim is a good boy. Spotlight will find all documents containing those 5 words, but not those 5 words together. There has to be a way...
    MacBook   Mac OS X (10.4.8)  

    First, thanks, I did. My naive take is that new plug-ins wouldn't be required.
    Second - I don't know about Google finding every document, but it returns some pretty impressive results, and fast (so long as Google indexes the page in the first place of course). You've never used this feature? I do it all the time when I want to see if there's an internet version of a document I have in my hand.
    Here's a random example the feature in action - I went to boingboing.net and snagged a phrase from the October archives: "You should give props to BabyStyle.com for the blue octopus costume". Here's the link to the October page:
    http://boingboing.net/200610_01archive.html
    and here's the link to the successful Google search:
    http://www.google.com/search?num=50&hl=en&lr=&safe=off&c2coff=1&client=firefox-a &rls=org.mozilla%3Aen-US%3Aofficial&q=%22Youshould+give+props+to+BabyStyle.com+for+the+blue+octopuscostume%22&btnG=Search
    Pretty impressive - the internet is a big place!
    Thirdly, there was a program written for OS 9 called "Gopher" that did just that. It was pretty handy. Come to think of it, it may have been written for System 8! It vanished from publication before there was even a web for it to be distributed on, and when I switched to OS X, it wasn't working well under 9. Of course outside of the personal computing realm, there are well known database programs like Lexis and Nexis that perform exact phrase searches on their databases, which are pretty extensive (at least as large as most document collections on most personal computers, I'd venture). In fact if you've never used those programs they have some pretty powerful functions, like searching for any occurrence of a word within so many words of a second target word.
    I'll give you a couple of examples of where phrase searching might come in handy. Suppose I have a collection of e-mails or correspondence (I guess we all do) and I want to find the one in which I facetiously repeated the punchline to the chicken joke - "to get to the other side". (You have to grant I might have a reason for wanting this particular e-mail, okay?) Of course if I search on "get", "other" and "side" I may wind up with four or five hundred results; those are pretty common words. That doesn't help me much. A phrase search,however, will yield, I dunno, three or four documents. Bingo.
    Or, here. I work in an office creating documents all day long. I've been working in this office, on PCs, for 16 years. That's a lot of documents. I may create three dozen or more on a single subject. The documents are all on the same subject and all pretty much have the same words in them. Maybe I've got a single paragraph printed from one of them and want to find the source document. A simple word search will yield back 80% of the lot. A phrase search typed in from the paragraph is almost certainly unique, however, and will give me my document in a blink.
    (Um, I'd have to move all the documents to a Macintosh to do this, but you get the point I hope.)
    Spotlight says it finds "anything anywhere" on your computer. I would use a feature like this *all the time*. Why shouldn't it be able to do it?

  • How to search all files in folders/subfolders for one or more strings?

    I have a list of files (full path and file name) in Column D of my worksheet.  I'm trying to figure out how to run some code to open each file in this array (starting on D14 and going down), search for one or more strings, and then put an "X"
    in Column I, in the same row as the file name.
    How can I do that?
    I experimented with a few samples of code.  It seems pretty easy to do it in one folder, but not all sub folders.  The folder/subfolder is setup a specific way for a specific purpose.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Below is an example that allow you to search a directory and its subdirs txt files(you can change this), read its lines and search for specific word:
    using System;
    using System.IO;
    using System.Linq;
    class Program
    static void Main(string[] args)
    try
    var files = from file in Directory.EnumerateFiles(@"c:\", "*.txt", SearchOption.AllDirectories)
    from line in File.ReadLines(file)
    where line.Contains("Microsoft")
    select new
    File = file,
    Line = line
    foreach (var f in files)
    Console.WriteLine("{0}\t{1}", f.File, f.Line);
    Console.WriteLine("{0} files found.", files.Count().ToString());
    catch (UnauthorizedAccessException UAEx)
    Console.WriteLine(UAEx.Message);
    catch (PathTooLongException PathEx)
    Console.WriteLine(PathEx.Message);
    https://msdn.microsoft.com/en-us/library/dd997370%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
    Fouad Roumieh

  • Finding Occurances of words within one whole string! Sorting

    Dear Algorithem Enthusiasts
    I'm trying to write up an algorithem to:
    Input:
    String s: appleappleapple
    Output:
    String keyword = apple;
    int numRep = 3;
    I have been expriencing problems especially when trying to handle more tricky strings such as:
    String trouble = mammalmammalmammalmammal;
    Where I shoud get Mammal & 4 respectivly.
    public class TEST
        public static void main(String args [])
            String Code ="googlegooglegooglegoogle";
            int strSize = Code.length();
            char a = Code.charAt(0);
            for(int i=0; i<strSize; i++)
             char b = Code.charAt(i);  
                if(a==b)
                  //I Found Occurance of first element?
                  //Now should i look  for occurance for second element? Will I also look for third? Where do I stop?
    }Thanks
    Seppi
    Edited by: seppi2008 on Dec 5, 2008 10:44 AM
    Edited by: seppi2008 on Dec 5, 2008 10:46 AM

    seppi2008 wrote:
    Hello
    thats a Very Clean Solution using Regrex
    replaceAll(String regex, String replacement)
    Replaces each substring of this string that matches the given regular expression with the given replacement.
    Looking at API + Summary of regular-expression constructs I cant seem to get my head round the arguments.
    String word = s.replaceAll("(.+?)\\1+$", "$1")$ = new line
    // = backlash why is it used
    (.+?) = capturing group?
    1 = is that group?
    Thanks SeppiNo, not quite:
    // regex:
    (                 // open capturing group 1
      .+?             //   match one or more characters of aby type, reluctantly matched
    )                 // close capturing group 1
    \\1+              // macth one or more substrings that have been matched by group 1
    $                 // the end of the string
    // replacement
    $1                // group 1The trick lies in the question mark (reluctant quantifier) after the DOT-PLUS. If you remove it, you'd end up with greedy matches. For example, take the String:
    "aabaabaabaab"with the greedy regex:"(.+)\\1+$"then you would get the substring "aabaab" instead of "aab".
    And the $ (end of string) is also important. If you'd omit that, then then this happens:
    String: "aabaabaabaab"
             ^^
                             // replaced by:    'a'
               ^..^..^..     // replaced by:    'baa'
                             // remaining char: 'b'resulting in the end String "abaab".
    Hope that clears things up.

  • SEARCH function in Adobe Captivate 8 so that the user can search key words within a project?

    Hi, I am wondering if there is a way to implement a SEARCH function in Adobe Captivate 8 so that the user can search key words within a project?

    Hello again
    Click the slide in the film strip, then examine the properties. You name the slide in the properties. And once you name it, the name should appear below the slide in the film strip, Then when you choose to enable the TOC, what you have there pulls in as shown below:
    If you have already constructed your TOC and wish to change this later, repeat the steps of naming the slides. Then click the Reset TOC icon just above the Settings button in the TOC section of the Skin editor to pull in the new names.
    Cheers... Rick

  • Can you use Find/Change to search for many different words at once?

    I have an 80 page catalogue in Indesign (CS5) - it has several thousands of catalogue numbers listed as text within it. I've just been given a list of 1000 catalogue numbers to search for and if they appear, remove them - is there any way to search for them all in one go, rather than one by one?
    I've started using Find/Change to search for the catalogue numbers but seem to only be able to search one catalogue number at a time that way.
    Any ideas welcome!
    Thanks

    GREP can search for more than one phrase "at once" (i.e., in one operation), like this:
    word1|word2|word3
    -- the pipe | delimits the separate words. Then again, GREP Is Not Magic™. This --
    ...  a list of 1000 catalogue numbers to search for ...
    is a bit too much to copy-and-paste into the single Find What line. There is a limit of ten or twelve (or something) OR phrases you can use in GREP.
    On the other hand: GREP is great at finding numbers. If all of your catalogue numbers obey some basic rule, for instance "all of them consist of 6 digits and there are no other numbers with exactly 6 digits", well, that we can probably work with.

  • Finding a word within a string

    Hey everyone,
    Just having a little trouble with something.
    I'm trying to find a word -- that is, not a substring, an actual word as defined by the english language -- within a string.
    For example I don't want "hell" to be found in "hello".. only "hello" to be found.
    Currently i've got two strings, one is the sentance (String input), and one is the word to be found in the sentance (String word). I need the program to find the WORD, and then go back and search for the word again and again and again until it reaches the end of the string.
    This is what I've got thus far:
              for(i = 0; i < input.length(); i++)
                   // This statement checks the string "input" for the string "word" starting at offset 0 (as this is what the variable was first defined as)
                   if(input.indexOf(word, offset) >= 0)
                        // If it finds the word at all, this line increases the offset ahead of this word so it doesn't simply find the same word again
                        offset = offset + (input.indexOf(word)) + (word.length());
                        times++;
              }At the moment this searches for the sub-string, not the WORD which is what I would like it to do.
    What's the easiest way of going about this? I've been fiddling around trying to add extra sections to the if statement, for example
    if((input.indexOf(word, offset) >= 0) && (input.charAt(offset +1) == 32))(32 as in the ASCII character for a space, which would do what I wanted it to do)
    But I eventually get errors because at some stage or another the charAt is going to be higher than the actual length of the String. Plus, this only looks if there's a space next to the word - a word can be valid if it has a ! next to it for example, or a comma...
    Thanks for any help :)
    viddy

    I think there's a word boundary marker in regex. So it'd be "\\w+hello\\w+" or whatever the marker is, to be used with a Pattern instance.

  • RegEx search in dreamweaver

    We are currently internationalizing an application comprised
    of more than 1000 files. Most of the text strings have been
    replaced, however there might be a string left here and there.
    I need a regex search that will find any text strings that
    are embeeded in within tags, for example <td>Some
    text</td>. The search should ignore dynamic output such as
    <td>#application.Store.StoreName(request.StoreID)#</td>.

    The word im searching for is "COM_VIRTUEMART_ADMIN"
    In the directory in searching there are more than 70 .ini file.
    So now i open the search and replace and select the directory with all the .ini files.
    Search "Source Code" or "Text" same result.
    Find : "COM_VIRTUEMART_ADMIN"
    Replace :
    Options : Match Case
    If i than click on find all it found nothing. It said : "Done not found in 4 documents".  That's strange because there are a lot more documents in that directory

  • Exchange 2010 SP2 RU2 - Indexing backlog reached a critical limit of 48 hours or the number of items in the retry queue is greater than 10000 for one or more databases

    We have been getting intermittent SCOM alarms for our Exchange 2010 MBX server citing "Indexing backlog reached a critical limit of 48 hours or the number of items in the retry queue is greater than 10000 for one or more databases"
    I see events in EventViewer that SCOM is triggering on, but not whats generating the events or how else to test for them.
        get-eventlog -computername SERVERNAME -logname "Application" -after "03/14/2013" | ?{$_.eventid -eq "5604"} | select MachineName,EventID,EntryType,Message | ft -autosize
    One MS Forum post online says it is a bug in RU4, unclear if it may also be a bug in RU2 (our installed version).
        http://social.technet.microsoft.com/Forums/en-US/exchangesvradmin/thread/9dcb3011-9327-4935-9479-62b38a6ddd87
        "I was looking for the same error and found this.. it basically says that this is a bug in RU4 and RU4-v2...and it needs to be removed."
    tests using troubleshooting scripts find no issues with search indexer,
        [PS] C:\Program Files\Microsoft\Exchange Server\V14\scripts>.\Troubleshoot-CI.ps1
        Get-EventLog : No matches found
        At C:\Program Files\Microsoft\Exchange Server\V14\scripts\CITSLibrary.ps1:622 char:40
        + $msftesqlCrashes = get-eventlog <<<< -computername $Server -after $StartTime -logname "Application" -source $msftesqlServiceName | where {$_.eventId
        -eq $msftesqlCrashEventId}
            + CategoryInfo : ObjectNotFound: (:) [Get-EventLog], ArgumentException
            + FullyQualifiedErrorId : GetEventLogNoEntriesFound,Microsoft.PowerShell.Commands.GetEventLogCommand
        Name IsDeadLocked CatalogStatusArray
        SERVERNAME False {DATABASENAME\SERVERNAME, DATABASENAME\S...
        [PS] C:\Program Files\Microsoft\Exchange Server\V14\scripts>
    and tests against searches on each DB themselves show no issues and respond typically within 3 seconds.
        [PS] C:\Program Files\Microsoft\Exchange Server\V14\scripts>Test-ExchangeSearch | ft Server, Database, ServerGuid, ResultFound, SearchTimeInSeconds, Error -AutoSize
        Server Database ServerGuid ResultFound SearchTimeInSeconds Error
        SERVERNAME DATABASENAME b16e3461-257c-40dd-a9ad-99a5f41a927e True 2.937
    I also tried to check the Performance Viewer for the MSExchange Search Indexer and MXExchange Search Indices but am unsure which of the many metrics would indicate this issue.
    We have had no reports of search issues from our users and have been unable to duplicate any impairment in our testing.
    Does anyone else have any suggestions for tests to check or steps to take on this alert? Is it simply a false alarm or a timeout of other sorts during testing? We have 80 DAGs on this server (as well as all our servers, some of which have also reported the
    same alert) and the Test-ExchangeSearch command times out before completely testing all DAGs.

    Hi IAMChrisL,
    Any updates?
    Frank Wang
    TechNet Community Support

  • Pages:  How can I sort one column of words and not have it affect the other columns?

    How can I sort one column of words and not have it affect the other columns?  I have opened the inspector to the edit columns and rows under Table.  It will sort the column, but then it changes the other colums as well.  I know that if I use Numbers, it will work, but I want to know how to do the same thing in Pages.

    Hi Peter,
    Numbers sorts full rows on values in selected column(s). The technique for sorting a single column is essentially the same as Jerry is describing for Pages tables—separate the (data in the) column to be sorted, sort it, return it to the table.
    In Numbers the actual column may be separated from the original table, sorted, then returned. In Pages, the data must be extracted, sorted, then pasted back in, overwriting the unsorted data (if it was left in the original table).
    iWork tables follow a database model in which each row is a Record, and each column holds a Field within the records.
    As evidenced by the current question (and several similar questions arising in the Numbers community) that model doesn't apply to the way some users, especially some who come in from the MS Excel world, use tables.
    With Excels model—islands of data on a single large table, the ability to sort one or a selected few columns of data makes sense. One 'island' may comprise only cells AA21:AH50. Sorting that small 'table' should be possible without disturbing the rest of rows 21-30, which are probably part of one or more other 'data islands' in the sea that is a MS Excel spreadsheet.
    In Numbers, each of those 'islands' would be a separate Table, and that Table would be sortable without disturbing other Tables in the document.
    Regards,
    Barry

  • Please create "on-the-fly change search engine" option ALSO for when we mark [word] in a text, then right-click, then choose "Search [engine x] for [word]"?

    In Firefox 34, you have changed the search bar.
    The new style is perfect for those who always starts by typing in, letter for letter, the search term.
    People such as myself, we almost never type in the search term,
    but instead we mark a [word] in a text, right-click this marked [word], then select "Search [engine x] for [word]".
    Speaking for myself, I have now a total of 36 search engine providers, but I usually only use 7 of those.
    I use "Wikipedia (English)" most of the time..
    - but then I will switch to e.g. "AniDB" and use that one for 1 hour..
    - or switch to "Google" and use that one for 30 minutes..
    - or switch to "Wikipedia (Norwegian)" and use that one for 2 hours..
    - or switch to "Wiktionary (English)" and use that one for 15 minutes..
    ..and then I will switch back to "Wikipedia (English)" again.
    The way the search bar was in Firefox 33 and earlier, I could very easily switch the default search engine.
    Just one click to open the drop-down menu, then choose one.
    In Firefox 34, I have to choose "Tools" -> "Options", the "Search" tab..
    - before I can THEN click to open the drop-down menu.
    4 clicks instead of 1, that's like 400% more work..!
    Also, the fact that I have to go into "Options".. make this..
    ..I don't know how to put it, it's a kind of psychological barrier that I have to overcome each time.
    I mean, before Firefox 34, I went to the "Options" window like maybe 4 times each YEAR,
    now, I have to go there 4 times each DAY..!
    I am not saying you should revert to the old style Search bar,
    as I feel that those you are typing search terms are indeed very happy for this new style..
    Instead, I think of 2 possible ways to create happiness also for us that do mark text and choose "Search.."
    1) An "on-the-fly change search engine" option ALSO for when we mark [word] in a text, then right-click, then choose "Search [engine x] for [word]".
    This could work as a cascading menu option, where it says..
    Search for [word] in -> [engine x]
    ..and where [engine x] was the current default engine, and all the other engines was listed underneath,
    just like the drop-down menu when you switch the default engine.
    Additionally, you could have an on / off checkbox in the "Options" "Search" tab, where you had this option:
    "Change default search engine when choosing another from the drop-down menu"
    THIS would actually be PERFECT.. It would be even much BETTER than in Firefox 33 and earlier..! :-)
    2) If there are things with the first option that don't work (something I've missed etc),
    then maybe you could have an on / off checkbox in the "Options" "Search" tab, where you had this option:
    "Use old-style search bar"
    This would be off by default, but when switched on, it would give us the old Firefox 33 style Search bar.

    Strongly recommend Context Search extension which will solve your problem
    - https://addons.mozilla.org/en-US/firefox/addon/context-search/?src=search

Maybe you are looking for