Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0
    I have tried all your attempts at the expression I need.

    Both your expressions produce different results.

    This one:

    Code:
    (\bhum your\b)|(\byou\b.*?\bhum).*\s(\S+\s+\S+)

    only highlights hum and your in the first sentence... which is fine... even though I said I needed it to highlight all instance of hum and your/you

    It highlights you hum a confident lullaby in the second sentence... again missing the first You.

    The expression captures NOTHING in the last sentence...

    How might you think it works? Maybe I'm just not seeing it.

    This one:

    Code:
    \bhum\b.*?\b(?:(you)\b|(your)\b.*\s(\S+\s+\S+))|\b(?:(you)\b.*?\bhum\b|(your)\b.*\bhum\b.*\s(\S+\s+\  S+))
    matches only hum your song in the first sentence and in the second sentence only matchs You you hum and nothing in the third sentence.

    The first you in the second sentence is only matched because it is a run on from the first sentence. So if the second sentence was the only thing to be matched.... it wouldn't find the first You.

    The expression I said I made... works fine... except for the issue I mentioned in or just after that post...
  2. #17
  3. Anemic Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,866
    Rep Power
    9433
    Originally Posted by krptodr
    even though I said I needed it to highlight all instance of hum and your/you
    Kindly point out where you said that.

    Originally Posted by krptodr
    The expression captures NOTHING in the last sentence...
    Oh really?


    I'm going to say this as clearly as I can:

    Write a full paragraph with at least 3 sentences and 100 words describing exactly (a1) what example input strings you have, both valid and invalid, (a2) which of those strings should match, should not match, and why (b) how you will be applying the regular expression to them, (c) what you are using to apply the regular expression, (d) the language you are using, (e) the expected matches, and (f) the expected behavior given those matches.

    You have done some of A and D. Great. Please do the rest.
    Attached Images
  4. #18
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0
    I guess im just not understanding RegEx. I thought that anything that matches was only highlighted...

    The reason the last line wasn't highlighted was because of the casing... again..

    I do apologize if my last post seemed a bit nasty.

    I'll re-examine everything with my new understanding and post back with any findings.
  6. #19
  7. Anemic Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,866
    Rep Power
    9433
    The third sentence is completely highlighted because the "you hum" was at the beginning and, in that situation, you wanted the last two words. Thus the entire sentence gets matched.
  8. #20
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0
    Ok, so the expression works, but I realized other possibilities that I need to match for. I'll work on those... but in the mean time.. the program that is using my regex is removing my tags that say to ignore casing...

    How can the expression be used to and work and not have to worry about casing?
  10. #21
  11. Anemic Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,866
    Rep Power
    9433
    You tell .NET to ignore case with RegexOption(s?).IgnoreCase.
  12. #22
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0
    Originally Posted by requinix
    You tell .NET to ignore case with RegexOption(s?).IgnoreCase.
    But im not the person who developed the program, that I am using the regex expression in. So the only way to get around it is to have the expression be designed to not care about the casing.
  14. #23
  15. Anemic Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,866
    Rep Power
    9433
    Well that sucks.
    Code:
    (\b[Hh][Uu][Mm] [Yy][Oo][Uu][Rr]\b)|(\b[Yy][Oo][Uu]\b.*?\b[Hh][Uu][Mm]).*\s(\S+\s+\S+)
    Every letter gets replaced with a [UPPERlower].
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo