Hi,
Can anyone help me to find regular expression for the following in Perl?
"The string can only contain lower case letters (a-z) and no more than one of any letter."
For example: "table" is accepted, whether "dude" is not.
I have coded like this:
$str = "table";
if ($str =~ m/\b()\b/) {... (4 Replies)
Hi
I need to do this thing in awk (or perl?). I try to find out how can I identify 1st and 2nd result from the OR expression in gensub:
block='title Sata Mandriva
kernel /boot/vmlinuz
initrd /boot/initrd.img'
echo "$block" | awk '{ x=gensub(/(kernel|initrd) /,"\\1XXX","g"); print x }'
... (12 Replies)
I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly:
if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Hi,
I get the following when I cat a file *.log
xxxxx
=====
dasdas gwdgsg fdsagfsag agsdfag
=====
random data
=====
My output should look like :
If the random data after the 2nd ==== is null then OK should be printed else
the random data should be printed.
How do I go about this... (5 Replies)
Hi Guys
I have the following regex
$OSRELEASE = $1 if ($output =~ /(Mac OS X (Server )?10.\d)/);
output is currently
Mac OS X 10.7.5
when the introduction of Mac 10.8 output changes to
OS X 10.8.2
they have dropped the Mac bit so i changed the regex to be (2 Replies)
Hello,
I'm trying to get a quick help on regex since i'm not a regular programmer.
Below is the line i'm trying to apply my regex to..i want to use the regex in a for loop and this line will keep on changing.
subject=... (4 Replies)
Could anyone please make me understand how the ?= works below ..
After executing this I am getting the same output.
$string="I love chocolate.";
$string =~ s/chocolate(?= ice)/vanilla/;
print "$string\n"; (2 Replies)
I am not a big expert in regex and have just little understanding of that language.
Could you help me to understand the regular Perl expression:
^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{
------
This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Experts -
I found a script on one of the servers that I work on and I need help understanding
one of the lines.
I know what the script does, but I'm having a hard time understanding the grouping.
Can someone help me with this?
Here's the script...
#!/usr/bin/perl
use strict;
use... (2 Replies)
Discussion started by: timj123
2 Replies
LEARN ABOUT CENTOS
pcre32_copy_named_substring
PCRE_COPY_NAMED_SUBSTRING(3) Library Functions Manual PCRE_COPY_NAMED_SUBSTRING(3)NAME
PCRE - Perl-compatible regular expressions
SYNOPSIS
#include <pcre.h>
int pcre_copy_named_substring(const pcre *code,
const char *subject, int *ovector,
int stringcount, const char *stringname,
char *buffer, int buffersize);
int pcre16_copy_named_substring(const pcre16 *code,
PCRE_SPTR16 subject, int *ovector,
int stringcount, PCRE_SPTR16 stringname,
PCRE_UCHAR16 *buffer, int buffersize);
int pcre32_copy_named_substring(const pcre32 *code,
PCRE_SPTR32 subject, int *ovector,
int stringcount, PCRE_SPTR32 stringname,
PCRE_UCHAR32 *buffer, int buffersize);
DESCRIPTION
This is a convenience function for extracting a captured substring, identified by name, into a given buffer. The arguments are:
code Pattern that was successfully matched
subject Subject that has been successfully matched
ovector Offset vector that pcre[16|32]_exec() used
stringcount Value returned by pcre[16|32]_exec()
stringname Name of the required substring
buffer Buffer to receive the string
buffersize Size of buffer
The yield is the length of the substring, PCRE_ERROR_NOMEMORY if the buffer was too small, or PCRE_ERROR_NOSUBSTRING if the string name is
invalid.
There is a complete description of the PCRE native API in the pcreapi page and a description of the POSIX API in the pcreposix page.
PCRE 8.30 24 June 2012 PCRE_COPY_NAMED_SUBSTRING(3)