Solved

Regex expresssion help

Posted on 2013-06-18
16
159 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Title # Comments Views Activity
need some regex help 15 29
wordEnds java challenge 47 160
Can someone decipher this regex parameter? 6 45
Regular expression help 2 45
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…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…

726 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