2
votes
2answers
52 views

perl regular expression explanations

I am completely lost on this line of perl code $path =~ s|^\./|~/|; #change the path for prettier output I am assuming it has to do with regex. I have some understanding of regex but i just cant ...
3
votes
2answers
36 views

Efficiently matching a set of filenames with regex in Perl

I'm using Perl to capture the names of files in some specified folders that have certain words in them. The keywords in those filenames are "offers" or "cleared" and "regup" or "regdn". In other ...
0
votes
6answers
72 views

How can i change a substring in a matched string in a file in perl

I want the following change : Original : Format="%05dA1" StartValue="2" Format="%05dB1" StartValue="2" Format="%05dC1" StartValue="2" Modified: Format="%05dA2" StartValue="2" Format="%05dB2" ...
1
vote
3answers
39 views

Finding a particular value in an HTTP response using Perl

I have a little script in Perl, HTTP POST request my $request = $ua->post( $url, [ 'country' => 10, 'evalprice' => 0 ] ); my $response = $request->content; Now I know that in the ...
1
vote
5answers
76 views

substitution not working as I expect

I am trying to write a Perl script that will change a line that looks like this ... <li><em>01 &#8211; Chapters 1-4</em> &#8211; 00:14:36 <br /> ... and make it look ...
-6
votes
7answers
87 views

Perl: Parsing * delimited file [closed]

I have an input text file input.txt as shown a,2,3*b,4,5*c,7,3* I have to print the numbers as follows a,2,3 b,4,5 c,7,3
0
votes
1answer
46 views

Escape sequences vs predefined character classes (aka special regex characters) when encapsulated by double quotes

Perl, like Java and Python, has \s, the special regex character that matches whitespace, in addition to other special characters. In Perl, the following would not be valid: my $sentence = "The ...
-1
votes
1answer
101 views

Perl Regex Issue Matching x0D x0A x0C

I've got a text file that I am trying to parse. My issue is that in certain instances I am hitting a line and it's incorrectly moving to the next line. I have looked at the file where it's done this ...
4
votes
5answers
67 views

Lookaround assertions in Perl

im confused what is the use of these lookaround assertions in perl? example this one: (?=pattern) or the positive lookahead. So here's my questions: How are these useful? what sort of instances ...
1
vote
3answers
65 views

How to use regular expression to remove $ character in string?

I want to use regular expression to remove string with $ , % , # these three characters , but it seems can't remove $ and the error information shows undefined variable How can I solve this problem? ...
-1
votes
3answers
47 views

Stick a `*` to the closest next word during the parsing

I have the following line in the text: int* a, b; The expected result is: int *a, b; The following Perl code is supposed to produce the expected line: $line =~ s#\s*\*\s*#\s\*#g; ...
-2
votes
2answers
78 views

Why does this regex not evaluate to true in perl?

I'm wrapping my first content string in single quotes to simplify what I'm asking. Its not wrapped in my code. '{ # "ERROR" : [ # "generic error message" # ] # }' =~ { It seems like ...
1
vote
1answer
27 views

Extract regexp matches from a string

I was trying to capture matches in a string using this: $String = "Feb122013Jan222013"; my @Matches = ($String =~ /((Jan|Feb)\d\d\d\d\d\d)/g); foreach (@Matches) { printf("[$_]\n"); } ...
7
votes
3answers
114 views

Meaning of a bit of perl's Regular Expression?

I'm translating code from perl and I've come accross the following line $text =~ s/([?!\.][\ ]*[\'\"\)\]\p{IsPf}]+) +([\'\"\(\[\¿\¡\p{IsPi}]*[\ ]*[\p{IsUpper}])/$1\n$2/g; My question is, what does ...
0
votes
1answer
50 views

perl regex: stucked with regex capture

I'm trying to extract the time taken in a process from a log. For example the log contains(the relevant lines): Time for search copy=15 s. Time for content copy=45 s. Time for unzip reply=20 s. ...

1 2 3 4 5 177
15 30 50 per page