Sponsored Content
Full Discussion: How to remove /*...*/ ?
Top Forums UNIX for Beginners Questions & Answers How to remove /*...*/ ? Post 303032531 by bakunin on Tuesday 19th of March 2019 07:12:17 PM
Old 03-19-2019
Quote:
Originally Posted by MadeInGermany
This is a case for a mimimum match.
You are right: non-greedy matching takes care of a few cases. Still, what i said about regexps being unable to parse still stands. For instance, your perl-program would have problems with:

Code:
char foo[3]="/*"; char bar[3]="*/"; /* comment */

I admit, this (and some more cases i could cite) are fringe. Maybe the thread-O/P will never encounter any of these. But again, it is - in a strict sense - impossible to overcome all of these problems (some of them, yes, but not all) because a regexp engine cannot work as a parser.

I hope this helps.

bakunin
These 2 Users Gave Thanks to bakunin For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

smitty, remove user, remove directory as well..

hi, i am on aix. i used smitty to remove a user.. but then found that its directory still exists.... so i have to remove the directory manually... am i doing it the right way? (2 Replies)
Discussion started by: yls177
2 Replies

2. UNIX for Dummies Questions & Answers

remove except ...

hello, Sometimes I need to remove all the files except one or more.I mean, there are 90 files and I want to remove 88 of them. how can i do that?is it possible to tell the "rm" command not to remove specified files? (4 Replies)
Discussion started by: xyzt
4 Replies

3. Shell Programming and Scripting

remove me!

Clicked on post twice, sorry: https://www.unix.com/shell-programming-scripting/147954-grep-fixed-string-regex.html#post302469753 (1 Reply)
Discussion started by: teresaejunior
1 Replies

4. Shell Programming and Scripting

remove with [0-9]

My file has varied width references: width=10% style=width:5% width:1506% width:99.58% so I'm trying clear all the width calls with one procedure: 's/width= *%//' and 's/width=*%//'but neither is working. (6 Replies)
Discussion started by: dba_frog
6 Replies

5. Shell Programming and Scripting

How to remove ^I ?

not sure what is this but any can help me delete this ^I cat -A file.txt CLAS^I^I|890^I|7,10,12,341,305,308,29,54^M$ LCLS^I^I|891^I|7,10,12,341,305,308,29,54^M$ MURB^I^I|892^I|7,10,12,341,305,308,29,54^M$ LATI^I^I|893^I|7,10,12,341,305,308,29,54^M$ i want to remove the ^I^I... (2 Replies)
Discussion started by: posner
2 Replies

6. Shell Programming and Scripting

remove brackets and put it in a column and remove repeated entry

Hi all, I want to remove the remove bracket sign ( ) and put in the separate column I also want to remove the repeated entry like in first row in below input (PA156) is repeated ESR1 (PA156) leflunomide (PA450192) (PA156) leflunomide (PA450192) CHST3 (PA26503) docetaxel... (2 Replies)
Discussion started by: manigrover
2 Replies

7. Red Hat

Remove

Hi guys, I need to write a script so that when i execute the "rm" command, the file mentioned need to be copied to other folder and then be deleted. this should be done in back ground. can you please help me out?? (1 Reply)
Discussion started by: rajeshb6
1 Replies

8. AIX

Need to remove (LP)PP

Had increased FS system size (sample_lv) on particular disks hdisk189 hdisk190 in a shared FS but unfortunately given addnl size occupies the space on other disks hdisk78 hdisk40 too In case, need to remove the addnl lv size occupied on hdisk78 hdisk40. How to achieve it. Pls advice. ... (3 Replies)
Discussion started by: ksgnathan
3 Replies

9. Post Here to Contact Site Administrators and Moderators

Please remove this post/remove information from it

In this thread: /shell-programming-and-scripting/255687-organizing-text-file-capital-names-capital-word-capital-word.html (sorry i cant use links) that is not an example, those are real students names with real student login id's for the college i am attending and i am on that list. Please... (3 Replies)
Discussion started by: throwawayacc
3 Replies

10. UNIX for Beginners Questions & Answers

Bash to remove find and remove specific extension

The bash below executes and does find all the .bam files in each R_2019 folder. However set -x shows that the .bam extension only gets removed from one .bam file in each folder (appears to be the last in each). Why is it not removing the extension from each (this is $SAMPLE)? Thank you :). set... (4 Replies)
Discussion started by: cmccabe
4 Replies
Search::QueryParser(3pm)				User Contributed Perl Documentation				  Search::QueryParser(3pm)

NAME
Search::QueryParser - parses a query string into a data structure suitable for external search engines SYNOPSIS
my $qp = new Search::QueryParser; my $s = '+mandatoryWord -excludedWord +field:word "exact phrase"'; my $query = $qp->parse($s) or die "Error in query : " . $qp->err; $someIndexer->search($query); # query with comparison operators and implicit plus (second arg is true) $query = $qp->parse("txt~'^foo.*' date>='01.01.2001' date<='02.02.2002'", 1); # boolean operators (example below is equivalent to "+a +(b c) -d") $query = $qp->parse("a AND (b OR c) AND NOT d"); # subset of rows $query = $qp->parse("Id#123,444,555,666 AND (b OR c)"); DESCRIPTION
This module parses a query string into a data structure to be handled by external search engines. For examples of such engines, see File::Tabular and Search::Indexer. The query string can contain simple terms, "exact phrases", field names and comparison operators, '+/-' prefixes, parentheses, and boolean connectors. The parser can be parameterized by regular expressions for specific notions of "term", "field name" or "operator" ; see the new method. The parser has no support for lemmatization or other term transformations : these should be done externally, before passing the query data structure to the search engine. The data structure resulting from a parsed query is a tree of terms and operators, as described below in the parse method. The interpretation of the structure is up to the external search engine that will receive the parsed query ; the present module does not make any assumption about what it means to be "equal" or to "contain" a term. QUERY STRING
The query string is decomposed into "items", where each item has an optional sign prefix, an optional field name and comparison operator, and a mandatory value. Sign prefix Prefix '+' means that the item is mandatory. Prefix '-' means that the item must be excluded. No prefix means that the item will be searched for, but is not mandatory. As far as the result set is concerned, "+a +b c" is strictly equivalent to "+a +b" : the search engine will return documents containing both terms 'a' and 'b', and possibly also term 'c'. However, if the search engine also returns relevance scores, query "+a +b c" might give a better score to documents containing also term 'c'. See also section "Boolean connectors" below, which is another way to combine items into a query. Field name and comparison operator Internally, each query item has a field name and comparison operator; if not written explicitly in the query, these take default values '' (empty field name) and ':' (colon operator). Operators have a left operand (the field name) and a right operand (the value to be compared with); for example, "foo:bar" means "search documents containing term 'bar' in field 'foo'", whereas "foo=bar" means "search documents where field 'foo' has exact value 'bar'". Here is the list of admitted operators with their intended meaning : ":" treat value as a term to be searched within field. This is the default operator. "~" or "=~" treat value as a regex; match field against the regex. "!~" negation of above "==" or "=", "<=", ">=", "!=", "<", ">" classical relational operators "#" Inclusion in the set of comma-separated integers supplied on the right-hand side. Operators ":", "~", "=~", "!~" and "#" admit an empty left operand (so the field name will be ''). Search engines will usually interpret this as "any field" or "the whole data record". Value A value (right operand to a comparison operator) can be o just a term (as recognized by regex "rxTerm", see new method below) o A quoted phrase, i.e. a collection of terms within single or double quotes. Quotes can be used not only for "exact phrases", but also to prevent misinterpretation of some values : for example "-2" would mean "value '2' with prefix '-'", in other words "exclude term '2'", so if you want to search for value -2, you should write "-2" instead. In the last example of the synopsis, quotes were used to prevent splitting of dates into several search terms. o a subquery within parentheses. Field names and operators distribute over parentheses, so for example "foo:(bar bie)" is equivalent to "foo:bar foo:bie". Nested field names such as "foo:(bar:bie)" are not allowed. Sign prefixes do not distribute : "+(foo bar) +bie" is not equivalent to "+foo +bar +bie". Boolean connectors Queries can contain boolean connectors 'AND', 'OR', 'NOT' (or their equivalent in some other languages). This is mere syntactic sugar for the '+' and '-' prefixes : "a AND b" is translated into "+a +b"; "a OR b" is translated into "(a b)"; "NOT a" is translated into "-a". "+a OR b" does not make sense, but it is translated into "(a b)", under the assumption that the user understands "OR" better than a '+' prefix. "-a OR b" does not make sense either, but has no meaningful approximation, so it is rejected. Combinations of AND/OR clauses must be surrounded by parentheses, i.e. "(a AND b) OR c" or "a AND (b OR c)" are allowed, but "a AND b OR c" is not. METHODS
new new(rxTerm => qr/.../, rxOp => qr/.../, ...) Creates a new query parser, initialized with (optional) regular expressions : rxTerm Regular expression for matching a term. Of course it should not match the empty string. Default value is "qr/[^s()]+/". A term should not be allowed to include parenthesis, otherwise the parser might get into trouble. rxField Regular expression for matching a field name. Default value is "qr/w+/" (meaning of "w" according to "use locale"). rxOp Regular expression for matching an operator. Default value is "qr/==|<=|>=|!=|=~|!~|:|=|<|>|~/". Note that the longest operators come first in the regex, because "alternatives are tried from left to right" (see "Version 8 Regular Expressions" in perlre) : this is to avoid "a<=3" being parsed as "a < '=3'". rxOpNoField Regular expression for a subset of the operators which admit an empty left operand (no field name). Default value is "qr/=~|!~|~|:/". Such operators can be meaningful for comparisons with "any field" or with "the whole record" ; the precise interpretation depends on the search engine. rxAnd Regular expression for boolean connector AND. Default value is "qr/AND|ET|UND|E/". rxOr Regular expression for boolean connector OR. Default value is "qr/OR|OU|ODER|O/". rxNot Regular expression for boolean connector NOT. Default value is "qr/NOT|PAS|NICHT|NON/". defField If no field is specified in the query, use defField. The default is the empty string "". parse $q = $queryParser->parse($queryString, $implicitPlus); Returns a data structure corresponding to the parsed string. The second argument is optional; if true, it adds an implicit '+' in front of each term without prefix, so "parse("+a b c -d", 1)" is equivalent to "parse("+a +b +c -d")". This is often seen in common WWW search engines as an option "match all words". The return value has following structure : { '+' => [{field=>'f1', op=>':', value=>'v1', quote=>'q1'}, {field=>'f2', op=>':', value=>'v2', quote=>'q2'}, ...], '' => [...], '-' => [...] } In other words, it is a hash ref with 3 keys '+', '' and '-', corresponding to the 3 sign prefixes (mandatory, ordinary or excluded items). Each key holds either a ref to an array of items, or "undef" (no items with this prefix in the query). An item is a hash ref containing "field" scalar, field name (may be the empty string) "op" scalar, operator "quote" scalar, character that was used for quoting the value ('"', "'" or undef) "value" Either o a scalar (simple term), or o a recursive ref to another query structure. In that case, "op" is necessarily '()' ; this corresponds to a subquery in parentheses. In case of a parsing error, "parse" returns "undef"; method err can be called to get an explanatory message. err $msg = $queryParser->err; Message describing the last parse error unparse $s = $queryParser->unparse($query); Returns a string representation of the $query data structure. AUTHOR
Laurent Dami, <laurent.dami AT etat ge ch> COPYRIGHT AND LICENSE
Copyright (C) 2005, 2007 by Laurent Dami. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2009-09-30 Search::QueryParser(3pm)
All times are GMT -4. The time now is 02:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy