Sponsored Content
Top Forums Shell Programming and Scripting How to get exact match sentences? Post 302226387 by vanitham on Tuesday 19th of August 2008 12:24:19 AM
Old 08-19-2008
Quote:
Originally Posted by redoubtable
to retrieve the sentence you want which matches a certain pattern you do like so:
Code:
if ($word =~ /(.*?RNA[-\s]binding protein.*?)$/) { 
      print "$1\n"; 
}

If you have multiple patterns you either put them all on a list and check one by one or create an expression that allows spaces or '-' between words (but that could be faulty and you would lose track of things)
Hi,

I want to match $sentences with $word like this:

Code:
if($sentences=~/$word/)
{

}

Here $word refers to "RNA binding protein" OR "RNA-binding protein".

How can i write expression such that $sentences matches with $word(it should match "RNA binding protein" and "RNA-binding protein")?

$word should work for both conditions and $sentences should match $word!!

How can i do that?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Exact Match thru grep ?????

hey..... i do have text where the contents are like as follows, FILE_TYPE_NUM_01=FILE_TYPE=01|FILE_DESC=Periodic|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=B FILE_TYPE_NUM_02=FILE_TYPE=02|FILE_DESC=NCTO|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=M... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

2. Shell Programming and Scripting

How to match all array contents and display all highest matched sentences in perl?

Hi, I have an array with 3 words in it and i have to match all the array contents and display the exact matched sentence i.e all 3 words should match with the sentence. Here are sentences. $arr1="Our data suggests that epithelial shape and growth control are unequally affected depending... (5 Replies)
Discussion started by: vanitham
5 Replies

3. Shell Programming and Scripting

exact match in Perl

Hi By using select clause I'm trying to pull out the rows to a variable. If the variable has 0 row(s) selected then i'm printing some text message else printing some other text message if($xyz =~ m/0 row/) { print "0 rows "; } else { print " There are rows"; } By my problem... (4 Replies)
Discussion started by: pdreddy34
4 Replies

4. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

5. Shell Programming and Scripting

Exact match question

Hi, I have a file like follows . . . White.Jack.is.going.home Black.Jack.is.going.home Red.Jack.is.going.home Jack.is.going.home . . . when I make: cat <file> | grep -w "Jack.is.going.home" it gives: White.Jack.is.going.home Black.Jack.is.going.home Red.Jack.is.going.home... (4 Replies)
Discussion started by: salih81
4 Replies

6. Shell Programming and Scripting

Exact match and #

Hi friends, i am using the following grep command for exact word match: >echo "sachin#tendulkar" | grep -iw "sachin" output: sachin#tendulkar as we can see in the above example that its throwinng the exact match(which is not the case as the keyword is sachin and string is... (6 Replies)
Discussion started by: neelmani
6 Replies

7. UNIX for Dummies Questions & Answers

Interpolation if there is no exact match for value

Dear all, could you help me with following question. There are two datasets (below). I need to find match between BP values from data1 and data2, and add corresponding CM value from data2 into data1. if there is not exact match, the corresponding CM value should be calculated using interpolation.... (20 Replies)
Discussion started by: kush
20 Replies

8. Shell Programming and Scripting

Get the exact match of the string!

Hi All, I am breaking my head in trying to get a command that will exactly match my given string. I have searched net and found few of the options - grep -F $string file grep -x $string file grep "^${string}$" file awk '/"${string}"/ {print $0}' file strangely nothing seems to... (3 Replies)
Discussion started by: dips_ag
3 Replies

9. Shell Programming and Scripting

Grep exact match

Hello! I have 2 files named tacs.tmp and tacDB.txt tacs.tmp looks like this 0 10235647 102700 106800 107200 1105700 tacDB.txt looks like this 100100,Mitsubishi,G410,Handheld,,0,0,0 100200,Siemens,A53,Handheld,,0,0,0 100300,Sony Ericsson,TBD (AAB-1880030-BV),Handheld,,0,0,0... (2 Replies)
Discussion started by: Cludgie
2 Replies

10. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies
ntext(n)					     Alternative Bindings for the Text Widget						  ntext(n)

__________________________________________________________________________________________________________________________________________________

NAME
ntext - Alternative Bindings for the Text Widget SYNOPSIS
package require Tcl 8.5 package require Tk 8.5 package require ntext ?0.81? _________________________________________________________________ DESCRIPTION
The purpose of the ntext package is to make the text widget behave more like other text-editing applications. It makes the text widget more useful for implementing a text editor, and makes it behave in a way that will be more familiar to most users. The package provides a binding tag named Ntext for use by text widgets in place of the default Text binding tag. Package ntext 's functions and variables are contained entirely in the ::ntext namespace; its other code is contained in the binding tag Ntext. ntext has no exports to the global or other namespaces, and no new widget commands. It uses modified copies of the Tk code, leav- ing the original code, and the Text binding tag, unchanged. The differences between the Ntext binding tag and the default Text binding tag are in three categories: o Some Text bindings behave differently from most text-editing applications. Ntext gives these bindings more familiar behaviour. For details see ntextBindings. o When a logical line with leading whitespace is word-wrapped onto more than one display line, the wrapped display lines begin further to the left than the first display line, which can make the text layout untidy and difficult to read. Ntext can indent the wrapped lines to match the leading whitespace of the first display line (this facility is switched off by default). For details see ntex- tIndent. o When the user navigates or selects text, Tcl/Tk sometimes needs to detect word boundaries. Ntext provides improved rules for word boundary detection. For details see ntextWordBreak. The remainder of this page describes the basic use and configuration of all three aspects of Ntext. For more detailed information on the different facilities of Ntext, see the pages ntextBindings, ntextIndent, and ntextWordBreak. See Section EXAMPLE for how to apply the Ntext binding tag in place of the Text binding tag. CONFIGURATION OPTIONS
Ntext provides alternatives to a number of behaviours of the classic Text binding tag. Where there is an option, the Ntext behaviour (except for display-line indentation) is switched on by default. The behaviour of Ntext may be configured application-wide by setting the values of a number of namespace variables: ::ntext::classicAnchor o 0 - (default value) selects Ntext behaviour, i.e. the anchor point is fixed o 1 - selects classic Text behaviour, i.e. the anchor point is variable ::ntext::classicExtras o 0 - (default value) selects Ntext behaviour, i.e. several traditional Text bindings are de-activated o 1 - selects classic Text behaviour, i.e. all Text bindings are activated ::ntext::classicMouseSelect o 0 - (default value) selects Ntext behaviour, i.e. the anchor point for mouse selection operations is moved by keyboard navigation o 1 - selects classic Text behaviour ::ntext::classicWordBreak o 0 - (default value) selects Ntext behaviour, i.e. platform-independent, two classes of word characters and one class of non-word characters. o 1 - selects classic Text behaviour, i.e. platform-dependent, one class of word characters and one class of non-word characters o After changing this value, the matching patterns should be recalculated. See ntextWordBreak for details and advanced configuration options. ::ntext::classicWrap o 0 - selects Ntext behaviour, i.e. display lines of text widgets in -wrap word mode are indented to match the initial whitespace of the first display line of a logical line. If the widget already holds text when this value is set, a function call may be neces- sary. See ntextIndent for detailed instructions on the use of Ntext 's indentation. o 1 - (default value) selects classic Text behaviour, i.e. no indentation ::ntext::overwrite o 0 - (initial value) text typed at the keyboard is inserted into the widget o 1 - text typed at the keyboard overwrites text already in the widget o The value is toggled by the Insert key. EXAMPLE
To create a text widget .t and use the Ntext bindings: package require ntext text .t bindtags .t {.t Ntext . all} See bindtags for more information. SEE ALSO
bindtags, ntextBindings, ntextIndent, ntextWordBreak, re_syntax, regexp, text KEYWORDS
bindtags, re_syntax, regexp, text ntext 0.81 ntext(n)
All times are GMT -4. The time now is 01:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy