Sponsored Content
Full Discussion: Help with regex construction
Top Forums Shell Programming and Scripting Help with regex construction Post 302456122 by durden_tyler on Thursday 23rd of September 2010 08:49:48 AM
Old 09-23-2010
Another one in Perl -

Code:
$
$
$ cat f20
  aP      [1,P1]
  mP      [3,P2] [4,P2(1)]
 mC,mI    [5,C2]
  oP      [16,P222] [17,P222(1)] [18,P2(1)2(1)2] [19,P2(1)2(1)2(1)]
  oC      [21,C222] [20,C222(1)]
  oF      [22,F222]
  oI      [23,I222] [24,I2(1)2(1)2(1)]
  tP      [75,P4] [76,P4(1)] [77,P4(2)] [78,P4(3)] [89,P422] [90,P42(1)2]
          [91,P4(1)22] [92,P4(1)2(1)2] [93,P4(2)22] [94,P4(2)2(1)2]
          [95,P4(3)22] [96,P4(3)2(1)2]
  tI      [79,I4] [80,I4(1)] [97,I422] [98,I4(1)22]
  hP      [143,P3] [144,P3(1)] [145,P3(2)] [149,P312] [150,P321] [151,P3(1)12]
          [152,P3(1)21] [153,P3(2)12] [154,P3(2)21] [168,P6] [169,P6(1)]
          [170,P6(5)] [171,P6(2)] [172,P6(4)] [173,P6(3)] [177,P622]
          [178,P6(1)22] [179,P6(5)22] [180,P6(2)22] [181,P6(4)22] [182,P6(3)22]
  hR      [146,R3] [155,R32]
  cP      [195,P23] [198,P2(1)3] [207,P432] [208,P4(2)32] [212,P4(3)32]
          [213,P4(1)32]
  cF      [196,F23] [209,F432] [210,F4(1)32]
  cI      [197,I23] [199,I2(1)3] [211,I432] [214,I4(1)32]
$
$ x=155
$ perl -lne "/$x,(.*?)]/ && print \$1" f20
R32
$
$ x=24
$ perl -lne "/$x,(.*?)]/ && print \$1" f20
I2(1)2(1)2(1)
$
$ x=19
$ perl -lne "/$x,(.*?)]/ && print \$1" f20
P2(1)2(1)2(1)
$
$

tyler_durden
 

7 More Discussions You Might Find Interesting

1. Cybersecurity

Password Construction

Could someone please help, I am new to unix and I am trying to do the following: o Each password must have at least eight characters. Only the first eight characters are significant. PASSLENGTH is found in /etc/default/passwd and is set to 6. ... (1 Reply)
Discussion started by: tumbikikani
1 Replies

2. Shell Programming and Scripting

Matrix construction

Hi experts How to construct a rectangular matrix for a text file with 6012 rows and 2221 columns. Thank You (1 Reply)
Discussion started by: riyabio
1 Replies

3. Shell Programming and Scripting

Matrix construction

Hi I have to construct a rectangular matrix with 6012 rows and 2221 columns. Here the rows and columns were given by alphanumeric ids in a file named row.txt and column.txt respectively. with this row nd column ids I have to construct a matrix ie 6012*2221 and compare the column ids with... (0 Replies)
Discussion started by: riyabio
0 Replies

4. Shell Programming and Scripting

case construction for basic Arithmetics calculation

the scrip (q4.sh) should perform the following calcuation (+, -, / and *) it should be used like this: q4.sh number1 operation number2 I wrote it already but the "*" does not work. #!/bin/bash #Date: 2010.10.19 # un script qui utilisera une instruction case pour effectuer des opérations... (6 Replies)
Discussion started by: flash80
6 Replies

5. Web Development

Website construction nowaday!

Hello, Actually I am not sure how to ask this question, which is about the technique advance on website construction/design. Compared with HTML/CSS, which ones are the most popular for website construction? My colleague recommends Drupal for Linux platform. Any other? Thanks! Yifang (4 Replies)
Discussion started by: yifangt
4 Replies

6. Shell Programming and Scripting

Grep command construction

Hi, I have an array variable "arr" that reads string from a file "vari.txt". Thus, the array will be of variable length depending how many entries are present in "vari.txt" I use a for loop to traverse through the array. However, i need a grep command to grep for a file "output.txt" and... (3 Replies)
Discussion started by: mohtashims
3 Replies

7. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies
All times are GMT -4. The time now is 07:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy