Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

1 to 3 words that are between # symbols

Last post 03-13-2008, 1:03 AM by ddrudik. 3 replies.
Sort Posts: Previous Next
  •  03-12-2008, 10:26 PM 40271

    1 to 3 words that are between # symbols

    I have a CSV file... The separating characters are the "#" symbol.

    I am searching for between 1 and 3 words, no more.

    Some of the separators have sentences in them, I want to ignore those.

    I do NOT want to actually SELECT the # symbols. 

    I am using EDIT PLUS and a Macro Engine to do this, so i will be writing a simple Macro, I want to grab the 1-3 word entries that are between the # symbols, ignoring the actual # symbols themselves, and ignoring the sentences that are entries on their own. 

    The following are three examples of what I might find. 

    ###Word#####

    ###1 Word#####

    ###Word Word Word#####

     I feel like I am going insane, I am 90% new to regular expressions. I have used them before in macros in my edit plus, but now I have a serious project that I need to do this check on over 7,000 entries, and I have read the entire Internet on Reg Ex's and I am just dumbfounded. If you can help me I will be eternally grateful, if you can't? Meh... *shrugs* I'll figure something out. Thanks for anything...

     Almost forgot. There are some entries that are just the plain letter X capitalized. I want to ignore those too. Those would look like:

    #X##Word#####

    #X##2 Word#####

    #X##Word Word Word#####

  •  03-12-2008, 10:51 PM 40272 in reply to 40271

    Re: 1 to 3 words that are between # symbols

    Show some actual source text so that we can see the format, that might make your goal more clear.  Include in the actual source text samples that you do and do not want to match.


  •  03-12-2008, 11:22 PM 40273 in reply to 40272

    Re: 1 to 3 words that are between # symbols

    ####X##########Ezra# How many of Zattu's offspring returned from Babylon? 2:8#
    ####X##########Nehemiah# How many of Zattu's offspring returned from Babylon? 7:13#
    ####X##########2 Chronicles# How many officers did Solomon have? 8:10#
    ####X##########1 Kings# How many officers did Solomon have? 9:23#

    I am trying to avoid the #X# that are like the 5th Entry.

    I am trying to avoid the sentences, like " How many of Zattu's offspring returned from Babylon? 2:8"

    What I want to capture are the "Ezra", "Nehemiah", "2 Chronicles", and "1 Kings" 

    AND not only do I want to capture the entry like "Ezra" but I want to capture like "Ezra" and NOT like "#Ezra#" 


     

  •  03-13-2008, 1:03 AM 40274 in reply to 40273

    Re: 1 to 3 words that are between # symbols

    One possibility it to match all on:

    #+X#+((?:\S+\s){0,2}\S+)#+

    Group #1 is your target.

    Another would be to match all on:

    (?<=####X##########)[^#]*

    Group #0 would be your target.


View as RSS news feed in XML