I'm trying to fully escape/quote a directory path for use in a regular expression with no characters interpreted symbolically. Printable characters get \* and white space gets "*"
Is in a new line but why? ---------- Post updated at 06:59 PM ---------- Previous update was at 06:54 PM ----------
Well, this works fine but here strings seem quirky.
Mike
HI,
I want to cut end string from line.
e.g. i have following input line
/users/home/test.txt
I want to get end string 'test.txt' from above line and length of that end string will change and it always start after '/'.
Thanks,
Visu (7 Replies)
I have a comma delimited text file and need to appened ",000000" to the end of every line. For example:
Before:
"D700000","2006" ,"5000","Open Year" ,"Conversion" ,"Wk64","Productive Payroll $" ,1103.45
After:
"D700000","2006" ,"5000","Open Year" ,"Conversion" ,"Wk64","Productive Payroll... (3 Replies)
Hi, guys. I have one question:
I have a file called "group", the contents of it is below:
********************************
...
test:x:203:
sales:x:204:
repair:x:205:
research:x:206:brownj
...
***********
Now I want to add string ",sherrys" at the end of "research:x:206:brownj", so... (5 Replies)
Hello
How can I add a string (always the same) at the end of a specific line in a file...
The file is:
000000001 041 L $$aspa
000000001 088 L $$aJ.E.N. 551
000000001 090 L $$aINFORMES JEN
000000001 100 L $$aautor 1
----
000000002 041 L $$aeng
000000002 088 L $$aJ.E.N. 1... (13 Replies)
I've a problem to put .h end of the line..below my input file
fg_a
bb
fg_b
bb
fg_c
bb
fg_d
aa
fg_f
ee
and i want the output file as below
fg_a.h
bb
fg_b.h
bb
fg_c.h
bb
fg_d.h (6 Replies)
Dear All
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB... (5 Replies)
Platform: Solaris 10
I have a file like below
$ cat languages.txt
Spanish
Norwegian
English
Persian
German
Portugese
Chinese
Korean
Hindi
Malayalam
Bengali
Italian
Greek
Arabic
I want to append the string " is a great language" at end of each line in this file. (3 Replies)
Hi
I have a very large data file with several hundred columns and millions of lines.
The important data is in the last set of columns with variable numbers of tab delimited fields in front of it on each line.
Im currently trying sed to get the data out - I want anything beetween :RES and... (4 Replies)
Hi,
I have a file which is an extract of jil codes of all autosys jobs in our server.
Sample jil code:
**************************
permission:gx,wx
date_conditions:yes
days_of_week:all
start_times:"05:00"
condition: notrunning(appDev#box#ProductLoad)... (1 Reply)
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
LEARN ABOUT DEBIAN
string::random
String::Random(3pm) User Contributed Perl Documentation String::Random(3pm)NAME
String::Random - Perl module to generate random strings based on a pattern
SYNOPSIS
use String::Random;
$foo = new String::Random;
print $foo->randregex('ddd'); # Prints 3 random digits
print $foo->randpattern("..."); # Prints 3 random printable characters
or
use String::Random qw(random_regex random_string);
print random_regex('ddd'); # Also prints 3 random digits
print random_string("..."); # Also prints 3 random printable characters
DESCRIPTION
This module makes it trivial to generate random strings.
As an example, let's say you are writing a script that needs to generate a random password for a user. The relevant code might look
something like this:
use String::Random;
$pass = new String::Random;
print "Your password is ", $pass->randpattern("CCcc!ccn"), "
";
This would output something like this:
Your password is UDwp$tj5
If you are more comfortable dealing with regular expressions, the following code would have a similar result:
use String::Random;
$pass = new String::Random;
print "Your password is ",
$pass->randregex('[A-Z]{2}[a-z]{2}.[a-z]{2}d'), "
";
Patterns
The pre-defined patterns (for use with "randpattern()" and "random_pattern()") are as follows:
c Any lowercase character [a-z]
C Any uppercase character [A-Z]
n Any digit [0-9]
! A punctuation character [~`!@$%^&*()-_+={}[]|:;"'.<>?/#,]
. Any of the above
s A "salt" character [A-Za-z0-9./]
b Any binary data
These can be modified, but if you need a different pattern it is better to create another pattern, possibly using one of the pre-defined as
a base. For example, if you wanted a pattern "A" that contained all upper and lower case letters ("[A-Za-z]"), the following would work:
$foo = new String::Random;
$foo->{'A'} = [ 'A'..'Z', 'a'..'z' ];
or
$foo = new String::Random;
$foo->{'A'} = [ @{$foo->{'C'}}, @{$foo->{'c'}} ];
The random_string function, described below, has an alternative interface for adding patterns.
Methods
new
new max => number
Create a new String::Random object.
Optionally a parameter "max" can be included to specify the maximum number of characters to return for "*" and other regular
expression patters that don't return a fixed number of characters.
randpattern LIST
The randpattern method returns a random string based on the concatenation of all the pattern strings in the list.
It will return a list of random strings corresponding to the pattern strings when used in list context.
randregex LIST
The randregex method returns a random string that will match the regular expression passed in the list argument.
Please note that the arguments to randregex are not real regular expressions. Only a small subset of regular expression syntax is
actually supported. So far, the following regular expression elements are supported:
w Alphanumeric + "_".
d Digits.
W Printable characters other than those in w.
D Printable characters other than those in d.
. Printable characters.
[] Character classes.
{} Repetition.
* Same as {0,}.
? Same as {0,1}.
+ Same as {1,}.
Regular expression support is still somewhat incomplete. Currently special characters inside [] are not supported (with the
exception of "-" to denote ranges of characters). The parser doesn't care for spaces in the "regular expression" either.
Functions
random_string PATTERN,LIST
random_string PATTERN
When called with a single scalar argument, random_string returns a random string using that scalar as a pattern. Optionally,
references to lists containing other patterns can be passed to the function. Those lists will be used for 0 through 9 in the
pattern (meaning the maximum number of lists that can be passed is 10). For example, the following code:
print random_string("0101",
["a", "b", "c"],
["d", "e", "f"]), "
";
would print something like this:
cebd
BUGS
This is Bug Free(TM) code. (At least until somebody finds one...)
AUTHOR
Steven Pritchard <steve@silug.org>
SEE ALSO perl(1).
perl v5.10.0 2009-06-11 String::Random(3pm)