Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Regex expresssion help

Posted on 2013-06-18
16
Medium Priority
?
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
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

618 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