Solved

Regex expresssion help

Posted on 2013-06-18
16
157 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 275 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
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…

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