Regex Expression Replace


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Regex Expression Replace
# 8  
Old 07-26-2017
Try:
Code:
awk '$1=="wd:address_line_1"{$2="Test data"}1' RS=\< ORS=\< FS=\> OFS=\> file.xml

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sed: -e expression #1, char 20: unterminated address regex

I am trying to add word in last of particular line. the same command syntex is running on prompt. but in bash script give error."sed: -e expression #1, char 20: unterminated address regex" Please help. for i in `cat servername`; do ssh -q -t root@$i sed -i '/simple_allow_groups =/s/$/,... (4 Replies)
Discussion started by: yash_message
4 Replies

2. Shell Programming and Scripting

Hi im new to bash scripting I want to know what does the regex expression do ??

# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi (1 Reply)
Discussion started by: kevin298
1 Replies

3. Emergency UNIX and Linux Support

Regular expression (regex) clean up text

Hi, Server - MEDIAWIKI - MYSQL - CENTOS 5 - PHP5 I have a database import of close to a million pages into my wiki, mediawiki site, the format that were left with is not pretty, and I need to find a way to clean this up and present it nicely... I think regex is the best option as I can... (1 Reply)
Discussion started by: lawstudent
1 Replies

4. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

5. Shell Programming and Scripting

awk variables in regex expression ?

Hello, Could someone explain why this one returns nothing: $ x=/jon/ $ echo jon | awk -v xa=$x '$1~xa {print}' $ while the following works fine: $ x=jon $ echo jon | awk -v xa=$x '$1==xa {print}' $ jon and the following works fine: $ echo jon | awk '$1~/jon/ {print}' $ jon ... (3 Replies)
Discussion started by: vilius
3 Replies

6. Shell Programming and Scripting

help with simple regex expression

I am trying to grep the following line in a file using a bash shell: (..) admin1::14959:::::: (..) It works with the following expression (as expected) # cat file | grep ^*:: admin1::14959:::::: but it does not work with (not expected) # cat /etc/shadow | grep ^+:: I assume the... (2 Replies)
Discussion started by: schms
2 Replies

7. Shell Programming and Scripting

Creating a regex expression

Good morning all!! In my code I and looking through file /etc/syslog.congf and printing every line that has /var/log in it. I need to turn the if 9$line) into a regex code instead. #!/usr/bin/perl @file= 'cat /etc/syslog.conf'; //when foreach $line (@file){ if ($line =~... (3 Replies)
Discussion started by: bigben1220
3 Replies

8. UNIX for Advanced & Expert Users

Regular expression / regex substition on Unicode text

I have a large file encoded in Unicode that I need to convert to CSV. In general, I know how to do this by regular expression substitutions using sed or Perl, but one problem I am having is that I need to put a quotation mark at the end of each line to protect the last field. The usual regex... (1 Reply)
Discussion started by: thomas.hedden
1 Replies

9. Shell Programming and Scripting

Regular expression (regex) required

I want to block all special characters except alphanumerics.. and "."(dot ) character currently am using // I want to even block only single dot or multiple dots.. ex: . or .............. should be blocked. please provide me the reg ex. ---------- Post updated at 05:11 AM... (10 Replies)
Discussion started by: shams11
10 Replies

10. Shell Programming and Scripting

Replace if regex on specific column matches expression?

I am attempting to convert rewrite rules to Nginx, and since due to the mass amount of rewrites we must convert, I've been trying to write a script to help me on a specific part, easily. So far I have this: rewrite ^action/static/(+)/$ staticPage.php?pg=$1&%$query_string; What I want done... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies
Login or Register to Ask a Question
Tie::Hash::Regex(3pm)					User Contributed Perl Documentation				     Tie::Hash::Regex(3pm)

NAME
Tie::Hash::Regex - Match hash keys using Regular Expressions SYNOPSIS
use Tie::Hash::Regex; my %h; tie %h, 'Tie::Hash::Regex'; $h{key} = 'value'; $h{key2} = 'another value'; $h{stuff} = 'something else'; print $h{key}; # prints 'value' print $h{2}; # prints 'another value' print $h{'^s'}; # prints 'something else' print tied(%h)->FETCH(k); # prints 'value' and 'another value' delete $h{k}; # deletes $h{key} and $h{key2}; or (new! improved!) my $h : Regex; DESCRIPTION
Someone asked on Perlmonks if a hash could do fuzzy matches on keys - this is the result. If there's no exact match on the key that you pass to the hash, then the key is treated as a regex and the first matching key is returned. You can force it to leap straight into the regex checking by passing a qr'ed regex into the hash like this: my $val = $h{qr/key/}; "exists" and "delete" also do regex matching. In the case of "delete" all vlaues matching your regex key will be deleted from the hash. One slightly strange thing. Obviously if you give a hash a regex key, then it's possible that more than one key will match (consider c<$h{qw/./}>). It might be nice to be able to do stuff like: my @vals = $h{$pat}; to get all matching values back. Unfortuately, Perl knows that a given hash key can only ever return one value and so forces scalar context on the "FETCH" call when using the tied interface. You can get round this using the slightly less readable: my @vals = tied(%h)->FETCH($pat); ATTRIBUTE INTERFACE From version 0.06, you can use attributes to define your hash as being tied to Tie::Hash::Regex. You'll need to install the module Attribute::Handlers. METHODS
FETCH Get a value from the hash. If there isn't an exact match try a regex match. EXISTS See if a key exists in the hash. If there isn't an exact match try a regex match. DELETE Delete a key from the hash. If there isn't an exact match try a regex match. AUTHOR
Dave Cross <dave@mag-sol.com> Thanks to the Perlmonks <http://www.perlmonks.org> for the original idea and to Jeff "japhy" Pinyan for some useful code suggestions. COPYRIGHT
Copyright (C) 2001-8, Magnum Solutions Ltd. All Rights Reserved. LICENSE
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl(1). perltie(1). Tie::RegexpHash(1) perl v5.10.0 2008-06-30 Tie::Hash::Regex(3pm)