Sponsored Content
Top Forums Shell Programming and Scripting Automating find and replace REGEX expressions in a script Post 303045492 by bedtime on Friday 27th of March 2020 04:39:27 PM
Old 03-27-2020
Quote:
Originally Posted by balajesuri
You may try perl. When it comes to regex and string parsing, perl handles them beautifully. Of course, doesn't mean you don't have other options.
Thank you. I've done just that. Perl seems to be the perfect tool for this issue.


Sorry for the late reply.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

automating file search and replace text

Hi, I am trying something like this: Let's say I have a file called File1 with contents: x=-0.3 y=2.1 z=9.0 I have another file, File2, with contents: xx= yy= zz= (nothing after "="). What I want to do is get the value of x in File1 and set it to xx in File2, i.e., xx=-0.3. And the... (3 Replies)
Discussion started by: ommatidia
3 Replies

2. Shell Programming and Scripting

A simple find and replace without using any regex (bash)

Hi, I need to do an exact find and replace (I don't want to use regular expressions because the input comes from user). I want to find a line that matches the user's input text and replace it with an empty string. For example, let's say the user enters I love "Unix" and the contents of the... (2 Replies)
Discussion started by: srikanths
2 Replies

3. Shell Programming and Scripting

Search Replace with regular expressions

Hello I have this regular expression: </book>(?:\n)<collection>(.*)</collectioninfo> And I have this peace of text on a FILE <book bookid="3" title="the title 3" remaining = "50" price="100"> <reader readerid="1"><!]></reader> <reader readerid="2"><!]></reader> <reader... (1 Reply)
Discussion started by: dirdamalah
1 Replies

4. UNIX for Dummies Questions & Answers

Regular Expressions -- Find spaces outside

Hello, I need help with using grep and regular expressions.... I have a long list of about 1000 lines of Chinese flashcards. Here's a small excerpt: 意文 yìwén (given name) 貴姓 guìxìng (honorable surname) 貴 guì (honorable) 姓 xìng (one's surname is; to be surnamed; surname) 呢 ne (interrogative... (2 Replies)
Discussion started by: arduino411
2 Replies

5. Linux

A find and replace script

Hello everyone, I am trying to do a simple script (shell or perl) for a bioinformatic problem, where I want to use a list from file2 and append this information to file1 (output). Example: File1 >Apple1 GAGACGATTTATATATAGAAGAGAG >Banana2 CAGAGAGAGAGACCCCCCCCCCCC File2 >Apple1 ... (2 Replies)
Discussion started by: herasj01
2 Replies

6. Shell Programming and Scripting

FIND w/ multiple expressions

For reference i am still a newb at scripting, but i have what i think is a complex issue. I need to run a FIND on / to identify all files and print them to >> $TEMPFILE I need to avoid MVFS I need to avoid /var/tmp/nastmp/ I was trying find / \( -type d -name nastmp -prune \) -a \( -fstype... (4 Replies)
Discussion started by: nitrobass24
4 Replies

7. Shell Programming and Scripting

Find 2 expressions then print in a single line

Guys, need help. I have a file that contains something like this: abc def ghi jkl I want to print the first and last line of the file and the output should be in a single line. so, output should be like this: abc jkl (3 Replies)
Discussion started by: solidhelix08
3 Replies

8. UNIX for Advanced & Expert Users

Using find and regular expressions

Hi Could you please advise how can one extract from the output of find . -name "*.c" -print only filenames in the current direcotry and not in its subdirectories? I tried using (on Linux x86_64) find . -name "*.c" -prune but it is not giving correct output. Whereas I am getting... (9 Replies)
Discussion started by: tinku981
9 Replies

9. Shell Programming and Scripting

Find and Replace in Shell script

Friends, I have more than 1000 lines in text file which needs to be converted as UPPERCASE by adding _ com.sun.url=www.sun.com com.ssl.port=808 com.ui.path=/apps/ssi Expected output com.sun.url=_COM.SUN.URL_ com.ssl.port=_COM.SSL.PORT_ com.ui.path=_COM.UI.PATH_ Thanks in... (4 Replies)
Discussion started by: baluchen
4 Replies

10. Shell Programming and Scripting

sed find multiple expressions plus next next line

Hello I am trying to write sed code where it will look through the text for lines with specific expression "Started by user" and when found, will also add the following line, and also lines with another expression "Finished:" sed -n '/Started by user/, +1p, /Finished:/'... (4 Replies)
Discussion started by: dlesny
4 Replies
HTML::Tidy(3pm) 					User Contributed Perl Documentation					   HTML::Tidy(3pm)

NAME
HTML::Tidy - (X)HTML validation in a Perl object VERSION
Version 1.50 SYNOPSIS
use HTML::Tidy; my $tidy = HTML::Tidy->new( {config_file => 'path/to/config'} ); $tidy->ignore( type => TIDY_WARNING, typed => TIDY_INFO ); $tidy->parse( "foo.html", $contents_of_foo ); for my $message ( $tidy->messages ) { print $message->as_string; } DESCRIPTION
"HTML::Tidy" is an HTML checker in a handy dandy object. It's meant as a replacement for HTML::Lint. If you're currently an HTML::Lint user looking to migrate, see the section "Converting from HTML::Lint". EXPORTS
Message types "TIDY_ERROR", "TIDY_WARNING" and "TIDY_INFO". Everything else is an object method. METHODS
new() Create an HTML::Tidy object. my $tidy = HTML::Tidy->new(); Optionally you can give a hashref of configuration parms. my $tidy = HTML::Tidy->new( {config_file => 'path/to/tidy.cfg'} ); This configuration file will be read and used when you clean or parse an HTML file. You can also pass options directly to libtidy. my $tidy = HTML::Tidy->new( { output_xhtml => 1, tidy_mark => 0, } ); See <http://tidy.sourceforge.net/docs/quickref.html> or "tidy -help-config" for the list of options supported by libtidy. The following options are not supported by "HTML::Tidy": quiet messages() Returns the messages accumulated. clear_messages() Clears the list of messages, in case you want to print and clear, print and clear. If you don't clear the messages, then each time you call parse() you'll be accumulating more in the list. ignore( parm => value [, parm => value ] ) Specify types of messages to ignore. Note that the ignore flags must be set before calling "parse()". You can call "ignore()" as many times as necessary to set up all your restrictions; the options will stack up. o type => TIDY_INFO|TIDY_WARNING|TIDY_ERROR Specifies the type of messages you want to ignore, either info or warnings or errors. If you wanted, you could call ignore on all three and get no messages at all. $tidy->ignore( type => TIDY_WARNING ); o text => qr/regex/ o text => [ qr/regex1/, qr/regex2/, ... ] Checks the text of the message against the specified regex or regexes, and ignores the message if there's a match. The value for the text parm may be either a regex, or a reference to a list of regexes. $tidy->ignore( text => qr/DOCTYPE/ ); $tidy->ignore( text => [ qr/unsupported/, qr/proprietary/i ] ); parse( $filename, $str [, $str...] ) Parses a string, or list of strings, that make up a single HTML file. The $filename parm is only used as an identifier for your use. The file is not actually read and opened. Returns true if all went OK, or false if there was some problem calling tidy, or parsing tidy's output. clean( $str [, $str...] ) Cleans a string, or list of strings, that make up a single HTML file. Returns the cleaned string as a single string. INSTALLING LIBTIDY
HTML::Tidy requires that "libtidy" be installed on your system. You can obtain libtidy through your distribution's package manager (make sure you install the development package with headers), or from the libtidy website at <http://tidy.sourceforge.net/src/tidy_src.tgz>. CONVERTING FROM ";HTML::Lint" HTML::Tidy is different from HTML::Lint in a number of crucial ways. o It's not pure Perl "HTML::Tidy" is mostly a happy wrapper around libtidy. o The real work is done by someone else Changes to libtidy may come down the pipe that I don't have control over. That's the price we pay for having it do a darn good job. o It's no longer bundled with its "Test::" counterpart HTML::Lint came bundled with "Test::HTML::Lint", but Test::HTML::Tidy is a separate distribution. This saves the people who don't want the "Test::" framework from pulling it in, and all its prerequisite modules. BUGS &; FEEDBACK Please report any bugs or feature requests at the issue tracker on github http://github.com/petdance/html-tidy/issues <http://github.com/petdance/html-tidy/issues>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. Please do NOT use <http://rt.cpan.org>. SUPPORT
You can find documentation for this module with the perldoc command. perldoc HTML::Tidy You can also look for information at: o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/HTML-Tidy <http://annocpan.org/dist/HTML-Tidy> o CPAN Ratings http://cpanratings.perl.org/d/HTML-Tidy <http://cpanratings.perl.org/d/HTML-Tidy> o HTML::Tidy's issue queue at github http://github.com/petdance/html-tidy/issues <http://github.com/petdance/html-tidy/issues> o Search CPAN http://search.cpan.org/dist/HTML-Tidy <http://search.cpan.org/dist/HTML-Tidy> o Subversion source code repository http://github.com/petdance/html-tidy <http://github.com/petdance/html-tidy> ACKNOWLEDGEMENTS
Thanks to Jonathan Rockway and Robert Bachmann for contributions. AUTHOR
Andy Lester, "<andy at petdance.com>" COPYRIGHT &; LICENSE Copyright (C) 2005-2010 by Andy Lester This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2011-11-15 HTML::Tidy(3pm)
All times are GMT -4. The time now is 11:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy