for an array element $fields[$j] containing:
gb:AF367205.1 DB_XREF=gi:17225988 TID=Os.1005.1 CNT=36 FEA=FLmRNA
TIER=FL+Stack STK=9 UG=Os.1005 DEF=Oryza sativa 1-deoxy-D-xylulose
5-phosphate reductoisomerase precursor, mRNA, complete cds; nuclear gene for
plastid product. PROD=1-deoxy-D-xylulose 5-phosphate
reductoisomeraseprecursor FL=gb:AK059692.1 gb:AK099702.1 gb:AF367205.1
REP_ORG=O. sativa
i try to extract useful content by:
if (preg_match("/PROD=(.+)\s{2}/", $fields[$j], $match ) )
$fields[$j] = $match[1];
else if (preg_match("/UG_TITLE=(.+)\s{2}/", $fields[$j], $match ) )
$fields[$j] = $match[1];
else if (preg_match("/DEF=(.+)\s{2}/", $fields[$j], $match ) )
$fields[$j] = $match[1];
i have confirmed it is 2 spaces (i.e. not tab, linefeed, new line). i just
don't know why sometimes it gives me:
PROD=1-deoxy-D-xylulose 5-phosphate reductoisomeraseprecursor
FL=gb:AK059692.1 gb:AK099702.1 gb:AF367205.1
or more (i.e. run-on matching). i don't know if it deals anything with
matching as much as possible. i also tried:
"/DEF=(.+)\s{2}[A-Z].*/" but it still doesn't work. BTW, because i know
sometimes what i want is at the end, so i also use "/DEF=(.+)$|\s{2}/" but
it also doesn't work.
i really appreciate anybody could help on this. i feel really desperated as
i find difficult to find out relevant documentatoin to explain why this
special case fails. thanks a lot 4 1178
vito wrote: for an array element $fields[$j] containing:
gb:AF367205.1 DB_XREF=gi:17225988 TID=Os.1005.1 CNT=36 FEA=FLmRNA TIER=FL+Stack STK=9 UG=Os.1005 DEF=Oryza sativa 1-deoxy-D-xylulose 5-phosphate reductoisomerase precursor, mRNA, complete cds; nuclear gene for plastid product. PROD=1-deoxy-D-xylulose 5-phosphate reductoisomeraseprecursor FL=gb:AK059692.1 gb:AK099702.1 gb:AF367205.1 REP_ORG=O. sativa
i try to extract useful content by:
if (preg_match("/PROD=(.+)\s{2}/", $fields[$j], $match ) ) $fields[$j] = $match[1]; else if (preg_match("/UG_TITLE=(.+)\s{2}/", $fields[$j], $match ) ) $fields[$j] = $match[1]; else if (preg_match("/DEF=(.+)\s{2}/", $fields[$j], $match ) ) $fields[$j] = $match[1];
i have confirmed it is 2 spaces (i.e. not tab, linefeed, new line). i just don't know why sometimes it gives me:
PROD=1-deoxy-D-xylulose 5-phosphate reductoisomeraseprecursor FL=gb:AK059692.1 gb:AK099702.1 gb:AF367205.1
or more (i.e. run-on matching). i don't know if it deals anything with matching as much as possible.
Yeah thats it.
(.+)\s{2}
Is a greedy match, it will match to the last two spaces it finds and
not the first.
Adding a ? after the brackets make it a non greedy match.
(.+)?\s{2}
Tim
Tim wrote: Yeah thats it.
(.+)\s{2}
Is a greedy match, it will match to the last two spaces it finds and not the first. Adding a ? after the brackets make it a non greedy match.
(.+)?\s{2}
Good explanation, totally correct, but nort the right regex:
(.+)?\s{2}
means:
(A random character 1 or mor times) zero or once.
explanation was good, regex should be:
(.+?)\s{2}
As I've learned, correct me if I'm wrong, the ? to make a selector
non-greedy should be directly after the selector itself AFAIK.
Grtz,
--
Rik Wasmus
> Yeah thats it. (.+)\s{2}
Is a greedy match, it will match to the last two spaces it finds and not the first. Adding a ? after the brackets make it a non greedy match.
(.+)?\s{2}
Tim
thanks but it seems it doesn't work. adding one more ? at the end also
helps nothing. :(
"/DEF=(.+)?\s{2}?/"
> Good explanation, totally correct, but nort the right regex: (.+)?\s{2} means: (A random character 1 or mor times) zero or once.
explanation was good, regex should be:
(.+?)\s{2}
As I've learned, correct me if I'm wrong, the ? to make a selector non-greedy should be directly after the selector itself AFAIK.
you're correct! Thanks, it works. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kenneth McDonald |
last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate
feedback, suggestions, and criticism as I work towards finalizing the
API and feature sets. rex is a module intended to make...
|
by: Buddy |
last post by:
Can someone please show me how to create a regular expression to do the
following
My text is set to
MyColumn{1, 100} Test
I want a regular expression that sets the text to the following...
|
by: Neri |
last post by:
Some document processing program I write has to deal with documents
that have headers and footers that are unnecessary for the main
processing part. Therefore, I'm using a regular expression to go...
|
by: Dimitris Georgakopuolos |
last post by:
Hello,
I have a text file that I load up to a string. The text includes
certain expression like {firstName} or {userName} that I want to match
and then replace with a new expression. However,...
|
by: James D. Marshall |
last post by:
The issue at hand, I believe is my comprehension of using regular
expression, specially to assist in replacing the expression with other text.
using regular expression (\s*) my understanding is...
|
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I...
|
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: vito |
last post by:
I'm processing the following sequence with length more than 100k
1 cagatgctga taaaaaagtg tgttcctcat agcatttatt taattgaaat atttcaagaa
61 cttgaatgta ctaaaaattg agacaaacag tagcaaatca taaaaaaaaa...
|
by: Allan Ebdrup |
last post by:
I have a dynamic list of regular expressions, the expressions don't change
very often but they can change. And I have a single string that I want to
match the regular expressions against and find...
|
by: NvrBst |
last post by:
I want to use the .replace() method with the regular expression /^ %VAR
% =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)"
regular expression with "":...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |