|
Mailing Lists
|
Home /
Groups /
Regular Expressions (RegEx)
[URGENT] Incremental matches!
Hellois_maximum 11/19/08 08:21 A Are you using ColdFusion?Adrian Lynch 11/19/08 08:26 A Adrian Lynch wrote:is_maximum 11/19/08 12:11 P Adrian Lynch wrote:is_maximum 11/19/08 12:13 P > Thanks Adrian, No actually I am using Java Regex but I think they are alike.Peter Boughton 11/19/08 06:01 P Well, I have a tree structure in database in which each node has its ownis_maximum 11/20/08 10:18 A Wellis_maximum 11/20/08 12:33 P well guysis_maximum 11/22/08 02:12 P > consider the current position I have is "1.1.2.1.3"s. isaac dealey 11/19/08 01:15 P Hello I have a string we call it position and this is in the form of '1.2.1.1' consider the current position I have is "1.1.2.1.3" I need to extract the following values: 1 1.1 1.1.2 1.1.2.1 1.1.2.1.3 or if position is "1.1.2" I need: 1 1.1 1.1.2 is this possible by using Regex? thanks ----- -- Regards Mohammad Norouzi Help each other to reach the future faster http://pixelshot.wordpress.com Pixelshot Photoblog http://brainable.blogspot.com Brainable Blog -- View this message in context: http://www.nabble.com/-URGENT--Incremental-matches%21-tp20577717p20577717.html Sent from the Cold Fusion - RegEx mailing list archive at Nabble.com. Are you using ColdFusion? No need to use RegEx, it's a list so: <cfoutput> <cfloop list="#position#" index="i"> #i#<br /> </cfloop> </cfoutput> Not a complete solution for you but you can see how to get at all the list elements. Adrian Building a database of ColdFusion errors at http://cferror.org/ Hello I have a string we call it position and this is in the form of '1.2.1.1' consider the current position I have is "1.1.2.1.3" I need to extract the following values: 1 1.1 1.1.2 1.1.2.1 1.1.2.1.3 or if position is "1.1.2" I need: 1 1.1 1.1.2 is this possible by using Regex? thanks ----- -- Regards Mohammad Norouzi Adrian Lynch wrote: ----- Excess quoted text cut - see Original Post for more ----- Thanks Adrian, No actually I am using Java Regex but I think they are alike. I want not to use any for loop ----- -- Regards Mohammad Norouzi Help each other to reach the future faster http://pixelshot.wordpress.com Pixelshot Photoblog http://brainable.blogspot.com Brainable Blog -- View this message in context: http://www.nabble.com/-URGENT--Incremental-matches%21-tp20577717p20584340.html Sent from the Cold Fusion - RegEx mailing list archive at Nabble.com. Adrian Lynch wrote: ----- Excess quoted text cut - see Original Post for more ----- Thanks Adrian, No actually I am using Java Regex but I think they are alike. I want not to use any for loop ----- -- Regards Mohammad Norouzi Help each other to reach the future faster http://pixelshot.wordpress.com Pixelshot Photoblog http://brainable.blogspot.com Brainable Blog -- View this message in context: http://www.nabble.com/-URGENT--Incremental-matches%21-tp20577717p20584371.html Sent from the Cold Fusion - RegEx mailing list archive at Nabble.com. > Thanks Adrian, No actually I am using Java Regex but I think they are alike. > I want not to use any for loop Why not? Can you provide more context as to what you're actually doing? It might enable a better answer. You can do: ^\d for 1 ^\d(\.\d){1} for 1.1 ^\d(\.\d){2} for 1.1.2 ^\d(\.\d){3} for 1.1.2.1 etc Well, I have a tree structure in database in which each node has its own unique id as above, say 1.1.1.2.1 now by given a node and its position (the same id) I have to extract all its parents and return back to the client. the parents' ids are identified by that unique id (1, 1.1, 1.1.1 AND 1.1.1.2) if it was only one node there was no problem using a for loop but we may have hundreds of these nodes and should extract all of them each for a user concurrently and this is a performance issue now I am welcome if you can help me on this with anything better than Regex thanks Peter Boughton wrote: ----- Excess quoted text cut - see Original Post for more ----- Well Chris Porter, has just replied me with a smart solution but I can't test it right now until I get to work. I don't know why he can't post here. this is the solution: select * from NODE_TABLE where '1.1.1.2.1' like id + '%' and id not like '1.1.1.2.1%' We are using OpenJPA and Oracle database. I am eager to check if it works well Thanks all ----- -- Regards Mohammad Norouzi Help each other to reach the future faster http://pixelshot.wordpress.com Pixelshot Photoblog http://brainable.blogspot.com Brainable Blog -- View this message in context: http://www.nabble.com/-URGENT--Incremental-matches%21-tp20577717p20606201.html Sent from the Cold Fusion - RegEx mailing list archive at Nabble.com. well guys this works fine thank you all select * from NODE_TABLE where '1.1.1.2.1' like id + '%' and id not like '1.1.1.2.1%' ----- -- Regards Mohammad Norouzi Help each other to reach the future faster http://pixelshot.wordpress.com Pixelshot Photoblog http://brainable.blogspot.com Brainable Blog -- View this message in context: http://www.nabble.com/-URGENT--Incremental-matches%21-tp20577717p20639510.html Sent from the Cold Fusion - RegEx mailing list archive at Nabble.com. ----- Excess quoted text cut - see Original Post for more ----- I don't think there's a way to get that with a single regex... But this would work <cfset a = [] /> <cfloop index="x" list="1.1.2.1.3" delimiter="."> <cfset temp = a[arraylen(a)] /> <cfset temp = listappend(temp,x,".") /> <cfset arrayAppend(a,temp) /> </cfloop> -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog
|
May 23, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||