Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a regex for parsing Arabic Dates
    primarykey
    data
    text
    <p>I'm working on a program that is running a series of regexs to attempt to find a date within the DOM from a webpage. For example, in <a href="http://www.engadget.com/2010/07/19/windows-phone-7-in-depth-preview/" rel="nofollow noreferrer">www.engadget.com/2010/07/19/windows-phone-7-in-depth-preview/</a>, I would match "Jul 19th 2010" with my regex. Things were going fine in multiple formats and languages until I hit an Arabic webpage. As an example, consider <a href="http://islammaktoob.maktoobblog.com/" rel="nofollow noreferrer">http://islammaktoob.maktoobblog.com/</a>. The date July 18, 2010 appears in Arabic at the top of the post, but I can't figure out how to match it. Does anyone have any experience on matching Arabic dates? If someone could post an example or the regex they would use to match that Arabic date, it would be very helpful. Thank you! </p> <h3>Update:</h3> <p>Getting closer:</p> <pre><code>String fromTheSite = "كتبها اسلام مكتوب ، في 18 تموز 2010 الساعة: 09:42 ص"; NamedMatcher infoMatcher = NamedPattern.compile("(?&lt;Day&gt;[0-3]?[0-9]) (?&lt;Month&gt;يناير|فبراير|مارس|أبريل|إبريل|مايو|يونيو|يونيه|يوليو|يوليه|أغسطس|سبتمبر|أكتوبر|نوفمبر|ديسمبر|كانون الثاني|شباط|آذار|نيسان|أيار|حزيران|تموز|آب|أيلول|تشرين الأول|تشرين الثاني|كانون الأول) (?&lt;Year&gt;[1-2][0-9][0-9][0-9]) ", Pattern.CANON_EQ).matcher(fromTheSite); while(infoMatcher.find()){ System.out.println(infoMatcher.group()); System.out.println(infoMatcher.group("Day")); System.out.println(infoMatcher.group("Month")); System.out.println(infoMatcher.group("Year")); } </code></pre> <p>Gives me </p> <pre><code>18 تموز 2010 18 تموز 2010 </code></pre> <p>Why does the match appear out of order? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload