Sponsored Content
Top Forums Programming Regular Expression matching in PERL Post 302170536 by Legend986 on Tuesday 26th of February 2008 01:49:15 AM
Old 02-26-2008
Regular Expression matching in PERL

I am trying to read a file and capture particular lines into different strings:

Code:
LENGTH: Some Content here

TEXT: Some Content Here

COMMENT: Some Content Here

I want to be able to get (LENGTH: .... ) into one array and so on... I'm trying to use PERL in slurp mode but for some reason I'm having trouble. Can someone suggest me a better way?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expression matching a new line

I have written a script to test some isdn links in my network and I am trying to format the output to be more readable. Each line of the output has a different number of digits as follows... Sitename , spid1 12345678901234 1234567890 1234567 , spid2 1234567890 1234567890 1234567 Sitename , ... (1 Reply)
Discussion started by: drheams
1 Replies

2. Shell Programming and Scripting

regular expression in perl

hi, i want to extract the sessionID from this line. QnA Session Id : here the output should be-- QnA_SessionID=128589 Thanks NT (3 Replies)
Discussion started by: namishtiwari
3 Replies

3. Shell Programming and Scripting

Help: Regular Expression for Negate Matching String

Hi guys, as per subject I am having problem with regular expressions. Example, if i got a string "javax.servlet.http.HttpServlet.service" that may occurred anywhere within a text file. How can I used the negate pattern matching of regular expression? I tried the below pattern but it... (4 Replies)
Discussion started by: DrivesMeCrazy
4 Replies

4. Shell Programming and Scripting

Regular expression matching in BASH (equivalent of =~ in Perl)

In Perl I can write a condition that evaluates a match expression like this: if ($foo =~ /^bar/) { do blah blah blah } How do I write this in shell? What I need to know is what operator do I use? The '=~' doesn't seem to fit. I've tried different operators, I browsed the man page for... (3 Replies)
Discussion started by: indiana_tas
3 Replies

5. Shell Programming and Scripting

Regular expression matching

Hi, I have a variable in my script that gets its value from a procstack output. It could be a number of any length, or it could just be a '1' with 0 or more white spaces around it. I would like to detect when this variable is just a 1 and not a 1234, for example. This is as far as I got: ... (3 Replies)
Discussion started by: tmf33uk
3 Replies

6. Shell Programming and Scripting

Matching single quote in a regular expression

I trying to match the begining of the following line in a perl script with a regular expression. $ENV{'ORACLE_HOME'} I tried this regluar expession: /\$ENV\{\'ORACLE_HOME\'\}/ Instead of match, I got a blank prompt > It seems to be a problem with the single quote. If I take it... (11 Replies)
Discussion started by: JC9672
11 Replies

7. Shell Programming and Scripting

Hidden Characters in Regular Expression Matching Perl - Perl Newbie

I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense. ... (4 Replies)
Discussion started by: kittyluva2
4 Replies

8. 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

9. UNIX for Dummies Questions & Answers

delete lines matching a regular expression

I have a very large file (over 700 million lines) that has some lines that I need to delete. An example of 5 lines of the file: HS4_80:8:2303:19153:193032 153 k80:138891 HS4_80:8:2105:5544:43174 89 k88:81949 165 k88:81949 323 0 * = 323 0 ... (6 Replies)
Discussion started by: pathunkathunk
6 Replies

10. Shell Programming and Scripting

regular expression matching whole words

Hi Consider the file this is a good line when running grep '\b(good|great|excellent)\b' file5 I expect it to match the line but it doesn't... what am i doing wrong?? (ultimately this regex will be in a awk script- just using grep to test it) Thanks, Storms (5 Replies)
Discussion started by: Storms
5 Replies
xmerl(3erl)						     Erlang Module Definition						       xmerl(3erl)

NAME
xmerl - Functions for exporting XML data to an external format. DESCRIPTION
Functions for exporting XML data to an external format. EXPORTS
callbacks(Module) -> Result Types Module = atom() Result = [atom()] Find the list of inherited callback modules for a given module. export(Content, Callback) -> ExportedFormat Equivalent to export(Data, Callback, []) . export(Content, Callback, RootAttributes) -> ExportedFormat Types Content = [Element] Callback = atom() RootAttributes = [XmlAttributes] Exports normal, well-formed XML content, using the specified callback-module. Element is any of: * #xmlText{} * #xmlElement{} * #xmlPI{} * #xmlComment{} * #xmlDecl{} (See xmerl.hrl for the record definitions.) Text in #xmlText{} elements can be deep lists of characters and/or binaries. RootAttributes is a list of #xmlAttribute{} attributes for the #root# element, which implicitly becomes the parent of the given Con- tent . The tag-handler function for #root# is thus called with the complete exported data of Content . Root attributes can be used to specify e.g. encoding or other metadata of an XML or HTML document. The Callback module should contain hook functions for all tags present in the data structure. A hook function must have the follow- ing format: Tag(Data, Attributes, Parents, E) where E is the corresponding #xmlElement{} , Data is the already-exported contents of E and Attributes is the list of #xmlAt- tribute{} records of E . Finally, Parents is the list of parent nodes of E , on the form [{ParentTag::atom(), ParentPosition::inte- ger()}] . The hook function should return either the data to be exported, or a tuple {'#xml-alias#', NewTag::atom()} , or a tuple {'#xml-rede- fine#', Content} , where Content is a content list (which can be on simple-form; see export_simple/2 for details). A callback module can inherit definitions from other callback modules, through the required function '#xml-interitance#() -> [Modu- leName::atom()] . See also: export/2 , export_simple/3 . export_content(Es::Content, Callbacks) -> term() Types Content = [Element] Callback = [atom()] Exports normal XML content directly, without further context. export_element(E, CB) -> term() Exports a normal XML element directly, without further context. export_element(E, CallbackModule, CallbackState) -> ExportedFormat For on-the-fly exporting during parsing (SAX style) of the XML document. export_simple(Content, Callback) -> ExportedFormat Equivalent to export_simple(Content, Callback, []) . export_simple(Content, Callback, RootAttrs::RootAttributes) -> ExportedFormat Types Content = [Element] Callback = atom() RootAttributes = [XmlAttributes] Exports "simple-form" XML content, using the specified callback-module. Element is any of: * {Tag, Attributes, Content} * {Tag, Content} * Tag * IOString * #xmlText{} * #xmlElement{} * #xmlPI{} * #xmlComment{} * #xmlDecl{} where * Tag = atom() * Attributes = [{Name, Value}] * Name = atom() * Value = IOString | atom() | integer() Normal-form XML elements can thus be included in the simple-form representation. Note that content lists must be flat. An IOString is a (possibly deep) list of characters and/or binaries. RootAttributes is a list of: * XmlAttributes = #xmlAttribute{} See export/3 for details on the callback module and the root attributes. The XML-data is always converted to normal form before being passed to the callback module. See also: export/3 , export_simple/2 . export_simple_content(Content, Callback) -> term() Exports simple XML content directly, without further context. export_simple_element(Content, Callback) -> term() Exports a simple XML element directly, without further context. AUTHORS
<> xmerl 1.2.8 xmerl(3erl)
All times are GMT -4. The time now is 03:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy