locked
regex to extract year without following or leading digits RRS feed

  • Question

  • Dear Regex Experts,

    I have two regex patterns that I use in Python that need a little improvement.

    1. #m/d/yy month in Digits e.g. 1/2/98
    pattern1 = r'(\d{1}/\d{1}/\d{2})'

    I need an extra condition that after those final yy digits, there should be no other digits coming.
    If they do, it is covered by a different pattern or not actually a date.

    2. #yyyy e.g. 1984
    pattern2 = '(\d{4})'

    For the second pattern, I need to make sure that the year stands alone and has no more digits before or after.

    I would really appreciate any help.

    Tuesday, June 19, 2018 8:57 AM

All replies

  • I can't help you with your regex question, but I think that you should be aware that you're asking the question in a forum dedicated to Expression Design, a moribund application intended for editing graphics, wherein there is no need or ability to use regexes. Just sayin'...  ;-)

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Sunday, June 24, 2018 10:10 PM
  • Hi Scott. Thanks for the info. Is there a forum in the microsoft community space dedicated to regex? I couldnt find it.

    Wednesday, July 11, 2018 11:19 AM
  • Try googling it. I googled "python regex forum" and got a number of hits. Since you have a specific question, I would ask it in stackoverflow. Good luck!

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Saturday, July 14, 2018 7:44 PM