us, $phase, $job ) = ('')x3;
>
> }
> }
> }
> __DATA__
> Job ID: 52
> User: zdmuser
> Client: zdmhost
> Job Type: "EVAL"
> Current status: SUCCEEDED
> Current Phase: "ZDM_SETUP_TGT"
> Job ID: 53
> Current stat
: "ZDM_SETUP_TGT"
Job ID: 53
Current status: FAIL
Current Phase: END
> On Feb 25, 2025, at 8:49 AM, Asad wrote:
>
> Hi All,
>
> I have a requirement to use regex , find the Job ID for the Current status:
> SUCCEEDED and Current Phase: "ZDM_SETUP_TGT"
above
> or is there a more better way in grep or regex
>
>
> On Tue, Feb 25, 2025 at 10:22 PM Erick Paquin
> wrote:
>
>> You can use grep for this..
>>
>> ---
>> Erick Paquin
>>
>> On 25/02/2025 11:49 am, Asad wrote:
>> > Hi All,
>
The problem with grep is that line numbers may change so even if i do grep
-E SUCCEEDED|"\ "ZDM_SETUP_TGT\"" -B5 , it may not alway 5 line above or
is there a more better way in grep or regex
On Tue, Feb 25, 2025 at 10:22 PM Erick Paquin wrote:
> You can use grep for
You can use grep for this..
---
Erick Paquin
On 25/02/2025 11:49 am, Asad wrote:
Hi All,
I have a requirement to use regex , find the Job ID for the Current
status: SUCCEEDED and Current Phase: "ZDM_SETUP_TGT" from a file
which has data in the format gives below :
Job ID: 52
Use
Hi All,
I have a requirement to use regex , find the Job ID for the Current
status: SUCCEEDED and Current Phase: "ZDM_SETUP_TGT" from a file
which has data in the format gives below :
Job ID: 52
User: zdmuser
Client: zdmhost
Job Type: "EVAL"
...
Current status: SUC
Hi,
Yes, they are the same.
I like to use $_ only when the data comes in $_ naturally. Like in a for loop:
for (qw< abc >)
{
if ( !/\w+\d+/ )
{
print "not matched";
}
}
Otherwise, I have to write $_, then I prefer to name the variable something
descriptive instead.
Makes the code
Hello list,
are these statements the same in perl?
$ perl -le '$_="abc";if (!/\w+\d+/){print "not matched"}'
not matched
$ perl -le '$_="abc";if ($_ !~ /\w+\d+/){print "not matched"}'
not matched
or which is the better one?
Thanks.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
Fo
Mike:
> I stand properly scolded.
I didn't want to scold anyone, it seems I expressed myself wrong.
Sorry for that.
Regards,
/Karl Hammar
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
I stand properly scolded.
Mike
On 1/23/24 07:01, k...@aspodata.se wrote:
Please stop using my mail address when replying, I'm on the list and
don't want two copies of the same mail (it's not about you Mike).
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional command
Please stop using my mail address when replying, I'm on the list and
don't want two copies of the same mail (it's not about you Mike).
Mike
> Why is my Perl not working on that command?
>
> $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
> Unescaped left
Why is my Perl not working on that command?
$ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
Unescaped left brace in regex is illegal here in regex; marked by <--
HERE in m/a{ <-- HERE ,2}/ at -e line 1.
$
But this works:
$ perl -e 'exit(10) if "aaa"=~/a{0,2
have a problem and you say I will solve it with
regular expressions then you have two problems.
Ánimos!
Saludos
From: Claude Brown via beginners
Sent: Monday, January 22, 2024 10:49:50 PM
To: k...@aspodata.se ; beginners@perl.org
Subject: RE: regex
Jorge
Jorge,
Expanding on Karl's answer (and somewhat labouring his point) consider these
examples:
$a =~ /Jorge/
$a =~ /^Jorge/
$a =~ /Jorge$/
$a =~ /^Jorge$/
This shows that regex providing four different capabilities:
- detect "Jorge" anywhere in the string
- detect "Jorg
I agree that this is confusing, and I think many resources describing regex in
unhelpful ways is partly to blame.
descriptions like "pattern that matches against a string" and similar.
this implies that a regex has to match the string, but this is not the case.
a regex does not have to
aa"=~/a{,2}/;'
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE
in m/a{ <-- HERE ,2}/ at -e line 1.
and
% perldoc perlre
says
Quantifiers
Quantifiers are used when a particular portion of a pattern needs to
match a certain number (or numbers)
Jorge Almeida:
> On Mon, 22 Jan 2024 at 13:00, wrote:
> > Jorge Almeida:
> > > $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
...
> > {,n}Match at most n times
...
> Yes, I read it (several times). I still don't understand it (I understand
> what you're saying, and I trust you're right, I just
Jorge Almeida:
> Please help me to understand this:
> $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
> $ echo $?
> $ 10
In man perlre, under "Regular Expressions" it says:
{,n}Match at most n times
So /a{,2}/ matches "", "a", and "aa" and is ignorant about what
comes before and after (basica
Please help me to understand this:
$ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
$ echo $?
$ 10
Thanks
Jorge Almeida
On 2022-10-10 18:12, Henrik Park wrote:
I know "/" is a special character for regex, which should be escaped.
But if I put "/" in a variable and use the variable in regex, then it
doesn't need the explicit escape. Like this one:
$ perl -le '$delimiter="/
Hello
I know "/" is a special character for regex, which should be escaped.
But if I put "/" in a variable and use the variable in regex, then it
doesn't need the explicit escape. Like this one:
$ perl -le '$delimiter="/"; $str="hello/world/buddy
Add ^ as
[^a-zA-Z0-9]
Though there are probably a number of different ways to approach RegEx…
Wags ;)
WagsWorld
Hebrews 4:15
Ph(primary) : 408-914-1341
Ph(secondary): 408-761-7391
On Dec 31, 2021, 20:22 -0800, Piper H , wrote:
> Hello
>
> I know [a-zA-Z0-9] means words and numbers.
>
]
>
> You could do
>
> $string !~ m/[a-zA-Z0-9]/
>
>
> On Fri, Dec 31, 2021 at 10:23 PM Piper H wrote:
>
>> Hello
>>
>> I know [a-zA-Z0-9] means words and numbers.
>> But what's the reverse of this regex?
>>
>> Thank you.
>>
>
t what's the reverse of this regex?
>
> Thank you.
>
Hello
I know [a-zA-Z0-9] means words and numbers.
But what's the reverse of this regex?
Thank you.
Thanks very much.
@Chankey Pathak, which of those libraries does you recommend for this task?
Best regards,
Julius
On Tue, Sep 14, 2021 at 2:33 AM Ken Peng wrote:
> Or use GPT-3 who has a free online API.
> https://openai.com/blog/openai-api/
>
> regards
>
> On Mon, Sep 13, 2021 at 11:42 PM C
Or use GPT-3 who has a free online API.
https://openai.com/blog/openai-api/
regards
On Mon, Sep 13, 2021 at 11:42 PM Chankey Pathak
wrote:
> You can look into NLP https://metacpan.org/search?q=nlp
>
> On Mon, 13 Sept 2021 at 21:04, Julius Hamilton <
> juliushamilton...@gmail.com> wrote:
>
>> He
You can look into NLP https://metacpan.org/search?q=nlp
On Mon, 13 Sept 2021 at 21:04, Julius Hamilton
wrote:
> Hey,
>
> I'm not sure if this is possible, and if it's not, I'll explore a better
> way to do this.
>
> I would like to write a script which analyzes if a line of text is
> (likely) a
Hey,
I'm not sure if this is possible, and if it's not, I'll explore a better
way to do this.
I would like to write a script which analyzes if a line of text is (likely)
a broken natural language sentence, i.e., it is probably part of a
sentence, even if the start or end is not present, rather th
x27;\n" if
>> ($T=~/^((?:mr|mrs|miss|dr|prof|sir) .{5,}?)\n/smi);
>>
>> would give output:
>>
>> match3='Miss Jayne Doe' ''
> Perfect, thank you.
>
> I can't ignore $2 as it's in a loop with other regex that genuinely return
rof|sir)'. For example:
print "match3='$1' '$2'\n" if
($T=~/^((?:mr|mrs|miss|dr|prof|sir) .{5,}?)\n/smi);
would give output:
match3='Miss Jayne Doe' ''
Perfect, thank you.
I can't ignore $2 as it's in a loop with other regex that g
ot;match3='$1' '$2'\n" if
($T=~/^((?:mr|mrs|miss|dr|prof|sir) .{5,}?)\n/smi);
would give output:
match3='Miss Jayne Doe' ''
On Wed, 2 Dec 2020, Gary Stainburn wrote:
> I have an array of regex expressions that I apply to text returned from
>
I have an array of regex expressions that I apply to text returned from
tesseract.
Each match that I get then gets stored for future processing. However,
I'm struggling with one regex.
The problem is that:
1) with brackets round the titles it returns two matches.
2) without bracket
first looks
> like an IP address and the second looks like a file path. In other
> words I can't distinguish the difference between these two "types".
>
>
> > I know how to write regex to match each line, but don't get the good
> result
> > with one
looks
like an IP address and the second looks like a file path. In other
words I can't distinguish the difference between these two "types".
I know how to write regex to match each line, but don't get the good result
with one regex to match both lines.
Can you help?
right?
if ( $entry =~ m#([\d.]+)\s+(/\S+)# ) {
my ($ip, $path) = ($1, $2);
print "IP $ip asked for path $path\n";
On Fri, Oct 25, 2019 at 5:28 AM Илья Рассадин wrote:
> For example, this regex
>
> /(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/
>
>
That is a backslash followed by a forward slash. The backslash tells the
regex parser to treat the next character as a literal character. Useful for
matching periods, question marks, brackets, etc.
A period matches any character once and an asterisk matches the previous
character any number of
my $n = '[0-9]{1,3}';
if ( =~ ( m[ (?:$n\.){3} $n \s+ \S+ ]x )
{
# match
}
On Fri, Oct 25, 2019 at 3:37 AM Maggie Q Roth wrote:
> what's V.*?
>
> Maggie
>
> On Fri, Oct 25, 2019 at 6:28 PM Илья Рассадин wrote:
>
>> For example, this rege
what's V.*?
Maggie
On Fri, Oct 25, 2019 at 6:28 PM Илья Рассадин wrote:
> For example, this regex
>
> /(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/
>
> On 25.10.2019 13:23, Maggie Q Roth wrote:
> > Hello
> >
> > There are two primary types
For example, this regex
/(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/
On 25.10.2019 13:23, Maggie Q Roth wrote:
Hello
There are two primary types of lines in the log:
60.191.38.xx /
42.120.161.xx /archives/1005
I know how to write regex to match each line, but
Hello
There are two primary types of lines in the log:
60.191.38.xx/
42.120.161.xx /archives/1005
I know how to write regex to match each line, but don't get the good result
with one regex to match both lines.
Can you help?
Thanks,
Maggie
18 12:28:12' "+%s"
> 1539797292
> $ date -d '05-JUL-18 10:19:42 ' "+%s"
> 1530803982
>
> That's ignoring TZ
>
> On Tue, Nov 13, 2018 at 5:38 PM Asad wrote:
>
>> Hi Andy ,
>>
>> thanks for the reply . Yes the purpose
v 13, 2018 at 5:38 PM Asad wrote:
> Hi Andy ,
>
> thanks for the reply . Yes the purpose is to compare the
> timestamps ans yes these are the only two formats .
>
> Thanks,
>
> On Wed, Nov 14, 2018 at 2:48 AM Andy Bach wrote:
>
>> Calling upgrade.sql
12:28:12,447849 +02:
>
> > I created on regex : \d\d\.\d\d\.\d\d\s[012][0-9]:[0-5][0-9]>:[0-5][0-9]
> > this only matches : Calling apply.sql on 17.10.18 12:28:12,447849 +02:
>
> Right as your first string has word chars for the month, not digits. So, a
> straight forward, if
Calling upgrade.sql on 05-JUL-18 10.19.42.559000 PM -12
Calling apply.sql on 17.10.18 12:28:12,447849 +02:
> I created on regex : \d\d\.\d\d\.\d\d\s[012][0-9]:[0-5][0-9]>:[0-5][0-9]
> this only matches : Calling apply.sql on 17.10.18 12:28:12,447849 +02:
Right as your first string has w
On Mon, 12 Nov 2018 18:18:12 +0530
Asad wrote:
> Hi all ,
>
>I have two stings from logfile how can we have a common regex so
> that its parse datetime details for further parsing ;
>
> Calling upgrade.sql on 05-JUL-18 10.19.42.559000 PM -12
> Calling apply.
You could change the first portion of RegEx to
\d{2}[.\-](\d{2}|\D{3})[.\-]
This could cover all the valid Month codes, but this will look for the hyphen
or period and two digit month or three non digits and then the the hyphen or
period following. There is much more you could do, but this
Hi all ,
I have two stings from logfile how can we have a common regex so
that its parse datetime details for further parsing ;
Calling upgrade.sql on 05-JUL-18 10.19.42.559000 PM -12
Calling apply.sql on 17.10.18 12:28:12,447849 +02:
I created on regex : \d\d\.\d\d\.\d\d\s[012][0-9
tetime
from datetime import timedelta
Header = "*"
f3 = open ( r"D:\QI\logA.txt", 'r' )
string = f3.read ()
regex = re.compile ( "\n" )
st = regex.sub ( " ", string )
st1 = st.split ( " "
= open ( r"D:\QI\logA.txt", 'r' )
> string = f3.read ()
> regex = re.compile ( "\n" )
> st = regex.sub ( " ", string )
> st1 = st.split ( " " )
>
> if re.search ('ERR-1:', st ):
> x = re.findall ( "(\w{3})\s+([
Hi ,
Yes i have the code :
import re
import datetime
from datetime import timedelta
Header = "*"
f3 = open ( r"D:\QI\logA.txt", 'r' )
string = f3.read ()
regex = re.compile ( "\n" )
st = regex.sub (
(Please reply to the list.)
If you have written code that extracts the date and time from the ‘LOG flle
opened’ lines in the log file, then please show us your code. You seem to be
asking other people to write your program for you. You will get better help if
you appear to be making an effort t
> On Oct 24, 2018, at 9:54 PM, Asad wrote:
>
> Thank all now I am able to progress :
>
> file1 i am able to extract the start and end timestamp
> file 2 i am able to extract the timestamp
>
> used the following
> my $t1 = Time::Piece->strptime('Feb 23 01:10:28 2018', '%b %d %H:%M:%S %Y'
Thank all now I am able to progress :
file1 i am able to extract the start and end timestamp
file 2 i am able to extract the timestamp
used the following
my $t1 = Time::Piece->strptime('Feb 23 01:10:28 2018', '%b %d %H:%M:%S
%Y'); coming from file1
my $t2 = Time::Piece->strptime('02/23/18 01:
Someone brought to my attention that I had failed to define a
couple of variables in the sample code I posted and they were
quite right. I don't mind sharing my work but the entire
application I wrote to get a brief local weather summary is
242 lines and I was trying to stay close to the topic, he
===> I am using the following regex :
([A-Z][a-z]{2}\s)([0-9]{2}\s[0-2][0-9](:[0-5][0-9]){2}\s[0-9]{4})
> Both are working as expected I would like to know if these are good regex
or it can be better , please suggest .
Concurring with the others, your setting yourself up for trouble wi
I cannot emphasize enough how fragile the perhaps obvious regex based
comparisons of timestamps can be. I second the approach demonstrated by
Илья Рассадин above. There are subtle and difficult to debug problems
buried in timestamps. Not least of which is locale ambiguity,
discontinuities like
Hi,
> Thank you all for the reply it is working for me .
>
> 1) for 02/23/18 01:10:33 ==> I am using the following regex
> \d\d/\d\d/\d\d\s[012][0-9]:[0-5][0-9]:[0-5][0-9]
> 2) Feb 23 01:10:28 2018
> > I am using the following regex :
> ([A-Z][a-z]{2}\s)([0-9]{2}
Thank you all for the reply it is working for me .
1) for 02/23/18 01:10:33 ==> I am using the following regex
\d\d/\d\d/\d\d\s[012][0-9]:[0-5][0-9]:[0-5][0-9]
2) Feb 23 01:10:28 2018
> I am using the following regex :
([A-Z][a-z]{2}\s)([0-9]{2}\s[0-2][0-9](:[0-5][0-9]){2}\s[
> first hurdle is how do I extract this Feb 23 01:10:28 2018 from file1
which regex
Look at perldoc -f stat
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
Not
Hi All ,
first hurdle is how do I extract this Feb 23 01:10:28 2018 from
file1 which regex can I use ?
convert it into epoch
then
regex for 02/23/18 01:10:33 is required ?
convert into epoch
So if you can suggest the correct regex for both
"Asad" wrote in message
news:cag3lskh4dphjg18c-jxmo8bcqfd+vix5tep1ytsp4_6pd6z...@mail.gmail.com...
Hi All ,
I need a regex to match the date : Sat Aug 25 08:41:03 2018 and
covert into a format :'%m/%d/%Y %H:%M:%S'
Thanks,
--
Asad Hasan
+91 95821116
Many Perl modules have been written to parse and manipulate dates and times.
Some come with Perl; others are available at www.cpan.org.
Check out the Date::Manip, Date::Parse, or DateTime modules.
> On Aug 25, 2018, at 4:06 AM, Asad wrote:
>
> Hi All ,
>
> I need a
Thanks, I'll check them out.
On Sat, Aug 25, 2018 at 4:53 PM Home Linux Info
wrote:
>
> Hello,
>
> Maybe not the most beautiful regex out there, hey I'm a noob, but it does
> the job right:
> ([A-Z][a-z]{2}\s)|([0-9]{2}\s[0-2][0-9](:[0-5][0-9]){2}\s[0-9]{4})
> You
Hello,
Maybe not the most beautiful regex out there, hey I'm a noob, but it
does the job right:
([A-Z][a-z]{2}\s)|([0-9]{2}\s[0-2][0-9](:[0-5][0-9]){2}\s[0-9]{4})
You can start from here and find a nicer form of this regex.
On 8/25/18 2:06 PM, Asad wrote:
Hi All ,
I need a
Really, no attempt to do it yourself?
Mike
On 8/25/2018 6:06 AM, beginners-digest-h...@perl.org wrote:
Hi All ,
I need a regex to match the date : Sat Aug 25 08:41:03 2018
and covert into a format : '%m/%d/%Y %H:%M:%S'
Thanks,
--
Asad Hasan
Hi All ,
I need a regex to match the date : Sat Aug 25 08:41:03 2018 and
covert into a format : '%m/%d/%Y %H:%M:%S'
Thanks,
--
Asad Hasan
+91 9582111698
,}[0-9]*" to get the package name, it
> needs a little more work for right now it gets the last dash and first
> digit of package version. Then you can try "*([^a-zA-Z_+-]{3,})(.\d{1,})*
> ".
> The first regex gives the following result:
> *binutils-2*
> *compat-libcap1*
&
Hello,
You can begin with "*[a-zA-Z_+-]{3,}[0-9]*" to get the package name, it
needs a little more work for right now it gets the last dash and first
digit of package version. Then you can try "*([^a-zA-Z_+-]{3,})(.\d{1,})*".
The first regex gives the following result:
/b
Hi Asad,
On Fri, 27 Jul 2018 18:24:39 +0530
Asad wrote:
> Hi All ,
>
> I want to get a regex to actually get the rpm name and version for
> comparison :
>
>
> binutils-2.23.52.0.1-12.el7.x86_64",
> compat-libcap1-1.10-3.el7.x86_64"
> compat-lib
But if you have to use a regex, I suggest using the /x modifier to make it
easier to read an maintain the regex:
#!/usr/bin/perl
use strict;
use warnings;
for my $s (qw/binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64 compat-libstdc++-33-3.2.3-71.el7.i686/) {
my ($name
I would suggest you change your approach and user the query mode of RPM to get
your information instead of build up a regexp:
rpm -qa --queryformat "%{NAME}\n"
Duncs
From: Asad [mailto:asad.hasan2...@gmail.com]
Sent: 27 July 2018 13:55
To: beginners@perl.org
Subject: regex to g
I don't think a regex is the simplest and most maintainable way to get this
information. I think it is probably better to take advantage of the
structure of the string to discard and find information:
#!/usr/bin/perl
use strict;
use warnings;
for my $s (qw/binutils-2.23.52.0.1-12.el7.x
Hi All ,
I want to get a regex to actually get the rpm name and version for
comparison :
binutils-2.23.52.0.1-12.el7.x86_64",
compat-libcap1-1.10-3.el7.x86_64"
compat-libstdc++-33-3.2.3-71.el7.i686
(^[a-zA-Z0-9\-]*)\-\d'
First part of the regular expression is ^[a-zA
Hi Lauren,
On Fri, 27 Jul 2018 11:28:42 +0800
"Lauren C." wrote:
> greetings,
>
> I was doing the log statistics stuff using perl.
> There are chinese characters in log items.
> I tried with regex to match them, but got no luck.
>
> $ perl -mstrict -le '
oops that's perfect. thanks Shlomi.
On 2018/7/27 星期五 PM 1:26, Shlomi Fish wrote:
Hi Lauren,
On Fri, 27 Jul 2018 11:28:42 +0800
"Lauren C." wrote:
greetings,
I was doing the log statistics stuff using perl.
There are chinese characters in log items.
I tried with regex to matc
greetings,
I was doing the log statistics stuff using perl.
There are chinese characters in log items.
I tried with regex to match them, but got no luck.
$ perl -mstrict -le 'my $char="汉语"; print "it is chinese" if $char =~
/\p{Han}+/'
$ perl -mstrict -mutf8 -l
I think reading the official tutorial from begin is not that comfortable
to a newbie. I bought a book "Learning Perl, 6th Edition" for studying
step by step. thanks.
On 2018/7/18 星期三 AM 9:08, Uri Guttman wrote:
also i always recommend reading the entire perl FAQ as there are many
again but more
slowly to learn the key things and practice them. then reread sections
you need to know better as the core stuff will be somewhat familiar by
then and you can delve deeper. and after you are done with the tutorial,
read the full reference doc on the subject! the regex reference is
I did read them, but got no deep impression unless I met the issue. :)
Uri Guttman 写道:
On 07/17/2018 08:46 PM, Lauren C. wrote:
Thanks Gil. I think i know the difference of "\w+" and "\w*" now.
lauren, did you read the perlretut document? if not, you should. it
covers quantifiers early on a
On 07/17/2018 08:46 PM, Lauren C. wrote:
Thanks Gil. I think i know the difference of "\w+" and "\w*" now.
lauren, did you read the perlretut document? if not, you should. it
covers quantifiers early on as they are one of the fundamental features
of regexes. a key thing to learn is the {m,n}
yeah you explain that well. thanks.
Andy Bach 写道:
> But it doesn't work for this case:
$ perl -le '$x="/path/"; print 1 if $x=~m{path/\w+}'
> it expects 1 returned.
Well, assuming you mean it shouldn't match as $x starts with a slash and
the RE doesn't - you're on the right path. The reas
r more of the previous thing.
Quantifier + : one or more of the previous thing.
So "/path/" won't match m{path/\w+} because this regex wants "one or more \w" at that
position, which the string doesn't have. If you use m{path/\w*} (note the asterisk) then you'
> But it doesn't work for this case:
$ perl -le '$x="/path/"; print 1 if $x=~m{path/\w+}'
> it expects 1 returned.
Well, assuming you mean it shouldn't match as $x starts with a slash and
the RE doesn't - you're on the right path. The reason is, the match goes
anywhere, it is "unanchored" so Pe
ier * : zero or more of the previous thing.
Quantifier + : one or more of the previous thing.
So "/path/" won't match m{path/\w+} because this regex wants "one or more \w"
at that position, which the string doesn't have. If you use m{path/\w*} (note
the asterisk) th
Hi!
I think, m{path/(\w+)?/?$} regex can solve your problem.
In general, to parse URL, you can use official regex from rfc3986 (see
Appendix B for rfc3986)
regex is
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
$2 is protocol
$4 is host
$5 is path
$7 is query
$9 is fragment
Hello,
I want to match:
/path/
/path/123
/path/abc
but /path/?xxx should not be matched.
This works:
$ perl -le '$x="/path/abc"; print 1 if $x=~m{path/\w+}'
1
this works too:
$ perl -le '$x="/path/?abc"; print 1 if $x=~m{path/\w+}'
But it doesn't work for this case:
$ perl -le '$x="/pa
Worked perfectly thanks, uri, and same technique works perfectly in
postgresql regexp_replace for info
On 29 June 2018 at 16:18, Mike Martin wrote:
> Thanks
>
>
> On Fri, 29 Jun 2018, 15:48 Uri Guttman, wrote:
>
>> On 06/29/2018 10:41 AM, Mike Martin wrote:
>>
>> sorry
>> -mm-dd hh:mm:ss.dd
Thanks
On Fri, 29 Jun 2018, 15:48 Uri Guttman, wrote:
> On 06/29/2018 10:41 AM, Mike Martin wrote:
>
> sorry
> -mm-dd hh:mm:ss.dd
> eg:
> 2018-01-01 12-45-10-456789 to
> 2018-01-01 12:45:10.456789
>
>
>
> please reply to the list and not to me!
>
> then why did you want lookbehind? this
On 06/29/2018 10:41 AM, Mike Martin wrote:
sorry
-mm-dd hh:mm:ss.dd
eg:
2018-01-01 12-45-10-456789 to
2018-01-01 12:45:10.456789
please reply to the list and not to me!
then why did you want lookbehind? this is very easy if you just grab the
time parts and reassemble them as you wan
On 06/29/2018 09:32 AM, Mike Martin wrote:
Hi
I am trying to convert a string of the format
2018-01-01 16-45-21-654278
to a proper timestamp string
so basically I want to replace all - after the date part
i am not sure what you are trying to do. show the after text that you
want. a proper t
Hi
I am trying to convert a string of the format
2018-01-01 16-45-21-654278
to a proper timestamp string
so basically I want to replace all - after the date part
I am getting a bit stuck, lookbehind doesnt seem to work as it includes the
lookbehind on every occurence
last attempt is
s/(?<= )-/:
Try:
binmode(HANDLE)
before reading the file.
HANDLE is your filehandle.
If that doesn't work you might want to supply the
text file and a sample script.
Mike
On 4/12/2018 12:04 PM, beginners-digest-h...@perl.org wrote:
I have a text file (created by pdftotext) that I've imported into my
On Thu, 2018-04-12 at 17:26 +0100, Gary Stainburn wrote:
> I have a text file (created by pdftotext) that I've imported into my
> script.
>
> It contains ASCII characters 251 for crosses and 252 for ticks.
ASCII defines 128 characters so those characters are not ASCII.
John
--
To unsubscribe
On Thursday 12 April 2018 19:53:16 Shlomi Fish wrote:
> Perhaps see http://perldoc.perl.org/perlunitut.html - you may need to read
> the file as binary or iso8859-1 or whatever. Also see
Thanks for this Shlomi. I have looked into that before briefly when doing http
gets and reading office documen
On Thu, 12 Apr 2018 17:26:57 +0100
Gary Stainburn wrote:
> I have a text file (created by pdftotext) that I've imported into my script.
>
> It contains ASCII characters 251 for crosses and 252 for ticks. If I load
> the file in gvim and do :as
>
> it reports the characters as
>
> 251, Hex
> However, when I try to seacch for it using
if ($line=~/[\xfb|\xfc]/) {
Note, you're mixing the character class " [ab] " with grouping alternative
pipe " ( a | b ) " here
> or even just
if ($line=~/\xfb/) {
Dunno, works here:
$ perl -e '$line = "hi" . chr 251 . "ho" . chr 252 ; if
($line=~/
I have a text file (created by pdftotext) that I've imported into my script.
It contains ASCII characters 251 for crosses and 252 for ticks. If I load the
file in gvim and do :as
it reports the characters as
251, Hex 00fb, Octal 373
252, hex 00fc, Octal 374
However, when I try to seacch f
Thanks Chas., that's interesting! Here's my summary of what I've learnt
from this:
1. The regex
$foo =~ "\Asome string\Z"
is equivalent to
$bar = "\Asome string\Z"; # ends up as 'Asome stringB' with a warning
$foo =~ /$bar/;
i.e evaluate the
Be careful, it isn't actually a regex; it is a string that will be compiled
to a regex. You can see one difference here:
#!/usr/bin/perl
use v5.20;
use warnings;
say "string matches:";
for my $s ("foo", "AfooZ") {
say "\t$s: ", $s =~ "\Afoo\Z
1 - 100 of 3347 matches
Mail list logo