find a location for property in a new city

Tuesday, 15 February 2011

Regex [x-y] range in reverse order

I started receiving a 'System.ArgumentException' error with a decription of 'parsing "[A-Za-z0-9_- %]+\.(bmp|jpg|jpeg|gif|png)" - [x-y] range in reverse order' after I wrote a C# Regex in my ASP.NET MVC web application.

I was using a RegularExpression Validator in my ASP.NET MVC app but it wasn't having any of it. I was looking at "A-Z" etc thinking IT IS THE RIGHT ORDER!

Turns out it is because I have a hyphen in another part of my regex expression. The one after the underscore.

Solution

Turns out hyphens have to appear at either the front or the end of the regular expression - or be escaped with a \. So now I have updated my regular expression from
[RegularExpression(@"[A-Za-z0-9_- %]+\.(bmp|jpg|jpeg|gif|png)")]
to
[RegularExpression(@"[A-Za-z0-9_ %-]+\.(bmp|jpg|jpeg|gif|png)")]

Follow britishdev on Twitter

29 comments:

  1. Thank you for posting this solution!

    ReplyDelete
    Replies
    1. The effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Final Year Projects for CSE.

      Software management seeks for decision support to identify technologies like JavaScript that meet best the goals and characteristics of a software project or improvement programme. JavaScript Training in Chennai Accessible experiences and repositories that effectively guide that technology selection are still lacking.

      Aim of technology domain analysis is to describe the class of context situations (e.g., kinds of JavaScript software projects) in which a software engineering technology JavaScript Training in Chennai can be applied successfully

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Awesome. Exactly what I needed.

    ReplyDelete
  3. Hannes
    Thanks!

    ReplyDelete
  4. Thank you. you saved my life

    ReplyDelete

  5. Thanks for posting this useful content, Good to know about new things here, Let me share this, . Hadoop training in pune

    ReplyDelete
  6. Replies
    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.

      Delete
  7. Interesting post! This is really helpful for me. I like it! Thanks for sharing!

    Webseiten Gestaltung Lüdenscheid

    ReplyDelete
  8. I found a lot of interesting information here. A really good post
    WebDesign Lüdenscheid

    ReplyDelete
  9. I have gone through your blog, it was very much useful for me and because of your blog, and also I gained many unknown information, the way you have clearly explained is really fantastic. Kindly post more like this, Thank You.
    remote java developer jobs

    ReplyDelete

  10. تنظيف منازل بالدمام تنظيف منازل بالدمام
    تنظيف منازل بالاحساء تنظيف منازل بالاحساء
    تنظيف منازل بمكة تنظيف منازل بمكة
    تنظيف منازل بجدة تنظيف منازل بجدة
    تنظيف منازل بالمدينة المنورة تنظيف منازل بالمدينة المنورة



    تنظيف بمكة شركة تنظيف بمكة بالبخار
    تنظيف بالمدينة المنورة تنظيف بالمدينة المنورة
    تنظيف بالجبيل افضل شركة تنظيف بالجبيل
    تنظيف بالدمام مؤسسة تنظيف بالدمام
    تنظيف بالخبر ارخص شركة تنظيف بالخبر


    ReplyDelete
  11. Buy t shirt for mens online from Dshred at best prices delivered at your doorstep. Get free shipping

    ReplyDelete
  12. Trueline Solution is leading Digital Marketing Company in Surat that provides services like SEO, SMM, ASO, SMO, PPC and many other digital marketing services and development services.
    ➡ Our Services:
    ✅ Website Design & Development
    ✅ Software Development
    ✅ Mobile App Development
    ✅ CRM / ERP Development
    ✅ Digital Marketing
    ✅ SEO / SEM / SMM / ASO
    ✅ Paid Promotion
    ✅ Graphics & Design
    ☎ +91 99132 99806 | +91 99132 99862

    ReplyDelete
  13. Laxmi pipe Industries is leading SS Pipe manufactures . We are also manufactures and exporter of steel pipes & tubes.

    ReplyDelete
  14. Keytexmachines is leading CNC Machining Job Work in surat With Excellent Quality, Cost Effective Price & Prompt Delivery. CNC Machining Job Work, CNC Turning Job Work, CNC Machine Service offered by Keytex machines, Surat.

    ReplyDelete
  15. DIYAM Impex Our Company DIYAM IMPEX. We have gone from strength to strength over the years, having expanded from our core business of diamond manufacturing to Real Estate, Renewable Energy and Venture Capital. Diamond has its many utility and its industrial value is enhanced by our effective services. We now focus exclusively on Lab Grown Diamonds. DIYAM IMPEX has grown to become a globally trusted and respected player in the diamond industry over the last five decades. Our expertise lies in our ability to produce a consistent supply of quality polished diamonds in all shapes and sizes.

    ReplyDelete
  16. Yami immigration is a well-known and experienced Best Student Visa Consultant in Surat. We provide Immigration Services for many countries such as Italy, Canada, France, Australia, Germany, USA, Malaysia, New Zealand, and Singapore.

    ReplyDelete
  17. Shreeja Health Care is leading manufacturer of Oil Maker Machine . Shreeja Oil Extraction Machine is able to extract oil from various seeds like peanuts, Coconut, Sesame, Soybean, macadamia nuts, walnuts, sunflower seeds, vegetable seeds flaxseed etc.

    ReplyDelete
  18. We SVJ Technocoat are the leading Service Provider and Exporter of an extensive array of PVD Coating Service and Vapor Deposition Coating Service etc. We are a well known firm for providing excellent quality coating services across the nation and in a timely manner. Owing to our improvised business models, our professionals are offering integrated solutions for our clients.

    ReplyDelete
  19. UID fashion designing course in surat is one of the Leading fashion institute in surat. professional fashion designing course in India is in demand these day by day, what can be best than pursuing fashion designing course from the fashion capital of India itself. Yes,UID fashion designing course in surat are talking about the city of surat, where you can have ample select when it comes to fashion design.

    ReplyDelete
  20. RQC is one of the Best Hair Transplant in surat, with services, including Hair Transplant, Hair Treatment, Hairfall and Hair Loss, dermatology, and Skincare. RQC brings you the best services in hair transplant, Hair Treatment.

    ReplyDelete
  21. Umano Logic web design edmonton based software development company founded in 2010 with over 10 years of experience. We had a team of creatives, analysts, and engineers that help you to bring your ideas to life. We are in the process to empower technology for the future. Get your FREE quote today. Lets Innovate Together!

    ReplyDelete
  22. RQC is one of the Best FUE Hair Transplant, with services, including Hair Transplant, Hair Treatment, Hairfall and Hair Loss, dermatology, and Skincare. RQC brings you the best services in hair transplant, Hair Treatment.

    ReplyDelete
  23. Shreeja is a global leading manufacturer, wholesaler, supplier, exporter of various small scale machinery. Shreeja oil extraction machine or Mini oil Ghani is one of our innovative product which is able to extract 100% pure oil from the various seed. We have a stronghold in national as well as a worldwide market.

    ReplyDelete