Solved

Regex expresssion help

Posted on 2013-06-18
16
154 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
Comment Utility
You can extract it from $1 -

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

Open in new window

0
 

Author Comment

by:zachvaldez
Comment Utility
What you mean?
you can extract from$1
0
 
LVL 21

Expert Comment

by:Mazdajai
Comment Utility
$1 is a backreferencing in regex you can refer to if you have parentheses () around.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
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 74

Expert Comment

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

Author Comment

by:zachvaldez
Comment Utility
I'm reading a PDF file. I don't use any editor.  I'm just looking for a regex formula.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:zachvaldez
Comment Utility
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
Comment Utility
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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
I tried but it's not appending the date.
0
 
LVL 21

Expert Comment

by:Mazdajai
Comment Utility
what is the output when you use the regex I posted?
0
 

Author Comment

by:zachvaldez
Comment Utility
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
Comment Utility
Can you post the output you are getting?
0
 

Author Comment

by:zachvaldez
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now