?
Solved

Regex expresssion help

Posted on 2013-06-18
16
Medium Priority
?
163 Views
Last Modified: 2013-08-09
I'm trying to save the file and I need to append dates to the splitted pdf.

The pattern is "Closing Date 3/01/13 thru 3/31/13"

I need to include 3/31/13. what is the best way to extract it?
0
Comment
Question by:zachvaldez
  • 8
  • 4
  • 4
16 Comments
 
LVL 21

Accepted Solution

by:
Mazdajai earned 1100 total points
ID: 39257825
You can extract it from $1 -

(\d{1,2}\/\d{1,2}\/\d{1,2})$

Open in new window

0
 

Author Comment

by:zachvaldez
ID: 39257898
What you mean?
you can extract from$1
0
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39257905
$1 is a backreferencing in regex you can refer to if you have parentheses () around.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39257955
Please provide a better description of what you are trying to do. It's not clear what you hope to gain from a regex based on your OP.
0
 

Author Comment

by:zachvaldez
ID: 39258175
I hope this is clear. From this pattern,
"Closing Date 3/01/13 thru 3/31/13"
how will I get.   3/31/13?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39258195
What language or text editor are you using?
0
 

Author Comment

by:zachvaldez
ID: 39258210
I'm reading a PDF file. I don't use any editor.  I'm just looking for a regex formula.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39258213
Then Mazdajai's suggestion should be what you need. If the tool doesn't support that syntax, then you might adjust it to:

([0-9][0-9]/[0-9][0-9]/[0-9][0-9])$

Open in new window

0
 

Author Comment

by:zachvaldez
ID: 39260502
yes, my date pattern pre Y2k as in
x/x/xx

or xx/xx/xx

what is the regex pattern to accommodate the month and day which can be either
1 or 2 digits?
0
 

Author Comment

by:zachvaldez
ID: 39260704
this is what I m trying to work on..
Since the search pattern is "thru 3/31/13"


(?<=thru \d{1}/\d{2}/)\d{2}  results to 13
(?<=thru )\d{1}(?=/\d{2}/\d{2}) results to 3
(?<=thru \d{1}/)\d{2}(?=/\d{2}) results to 31

But this regex pattern may not work if month has 2 digits and day has 1 digit.
I have to cover all possibilities.
Let me know what will I need to modify

I have to individually extract the digits.  thanks
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39260816
Have you tried Mazdajai's suggestion? The {1,2} he proposed should handle either a 1- or 2-digit day or month.
0
 

Author Comment

by:zachvaldez
ID: 39260985
I tried but it's not appending the date.
0
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39261011
what is the output when you use the regex I posted?
0
 

Author Comment

by:zachvaldez
ID: 39279393
It does not append the values.
I think it should be done in 3 lines.
for year,month,date.
0
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39279506
Can you post the output you are getting?
0
 

Author Comment

by:zachvaldez
ID: 39284615
It's not reading it. so I have a blank output. I use this..

(thru\d{1,2}\/\d{1,2}\/\d{1,2})$

the input is 3/31/13
the output I expect should be displayed

13331


 but Id like it ot show as 20130430
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question