Search Results

Search found 4539 results on 182 pages for 'regex grouping'.

Page 1/182 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • regex return conditional group

    - by priyank.mp
    Hi , I spent lot time figuring out a simple regex to return a group (only 1st group). So the string can be - "No purchase required" or "Purchase of $50.00 worth groceries is required." I am trying to write a regex which can parse "No" or "50" based on the given string. This is what I have written. (?:(No) monthly maintenance|Purchase of \$([\d\.]+ worth groceries) This works fine but I want my output as 1st group/group 1 only.

    Read the article

  • Dynamic Grouping and Columns

    - by Tim Dexter
    Some good collaboration between myself and Kan Nishida (Oracle BIP Consulting) over at bipconsulting on a question that came in yesterday to an internal mailing list. Is there a way to allow columns to be place into a template dynamically? This would be similar to the Answers Column selector. A customer has said Crystal can do this and I am trying to see how BI Pub can do the same. Example: Report has Regions as a dimension in a table, they want the user to select a parameter that will insert either Units or Dollars without having to create multiple templates. Now whether Crystal can actually do it or not is another question, can Publisher? Yes we can! Kan took the first stab. His approach, was to allow to swap out columns in a table in the report. Some quick steps: 1. Create a parameter from BIP server UI 2. Declare the parameter in RTF template You can check this post to see how you can declare the parameter from the server. http://bipconsulting.blogspot.com/2010/02/how-to-pass-user-input-values-to-report.html 3. Use the parameter value to condition if a particular column needs to be displayed or not. You can use <?if@column:.....?> syntax for Column level IF condition. The if@column is covered in user documentation. This would allow a developer to create a report with the parameter or multiple parameters to allow the user to pick a column to be included in the report. I took a slightly different tack, with the mention of the column selector in the Answers report I took that to mean that the user wanted to select more of a dimensional column and then have the report recalculate all its totals and subtotals based on that selected column. This is a little bit more involved and involves some smart XSL and XPATH expressions, but still very doable. The user can select a column as a parameter, that is passed to the template rather than the query. The parameter value that is actually passed is the element name that you want to regroup the data by. Inside the template we then reference that parameter value in our for-each-group loop. That's where we need the trixy XSL/XPATH code to get the regrouping to happen. At this juncture, I need to hat tip to Klaus, for his article on dynamic sorting that he wrote back in 2006. I basically took his sorting code and applied it to the for-each loop. You can follow both of Kan's first two steps above i.e. Create a parameter from BIP server UI - this just needs to be based on a 'list' type list of value with name/value pairs e.g. Department/DEPARTMENT_NAME, Job/JOB_TITLE, etc. The user picks the 'friendly' value and the server passes the element name to the template. Declare the parameter in RTF template - been here before lots of times right? <?param@begin:group1;'"DEPARTMENT_NAME"'?> I have used a default value so that I can test the funtionality inside the template builder (notice the single and double quotes.) Next step is to use the template builder to build a re-grouped report layout. It does not matter if its hard coded right now; we will add in the dynamic piece next. Once you have a functioning template that is re-grouping correctly. Open up the for-each-group field and modify it to use the parameter: <?for-each-group:ROW;./*[name(.) = $group1]?> 'group1' is my grouping parameter, declared above. We need the XPATH expression to find the column in the XML structure we want to group that matches the one passed by the parameter. Its essentially looking through the data tree for a match. We can show the actual grouping value in the report output with a similar XPATH expression <?./*[name(.) = $group1]?> In my example, I took things a little further so that I could have a dynamic label for the parameter value. For instance if I am using MANAGER as the parameter I want to show: Manager: Tim Dexter My XML elements are readable e.g. DEPARTMENT_NAME. Its a simple case of replacing the underscore with a space and then 'initcapping' the result: <?xdoxslt:init_cap(translate($group1,'_',' '))?> With this in place, the user can now select a grouping column in the BIP report viewer and the layout will re-group the data and any calculations based on that column. I built a group above report but you could equally build the group left version to truly mimic the Answers column selector. If you are interested you can get an example report, sample data and layout template here. Of course, you can combine Klaus' dynamic sorting, Kan's conditional column approach and this dynamic grouping to build a real kick ass report for users that will keep them happy for hours..

    Read the article

  • c# RegEx with "|"

    - by WtFudgE
    I need to be able to check for a pattern with | in them. For example an expression like d*|*t should return true for a string like "dtest|test". I'm no regex hero so I just tried a couple of things, like: Regex Pattern = new Regex("s*\|*d"); //unable to build because of single backslash Regex Pattern = new Regex("s*|*d"); //argument exception error Regex Pattern = new Regex(@"s*\|*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex(@"s*|*d"); //argument exception error Regex Pattern = new Regex("s*\\|*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex("s*" + "\\|" + "*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex(@"s*\\|*d"); //argument exception error I'm a bit out of options, what should I then use? I mean this is pretty basic RegEx i know, but I'm not getting it for some reason.. Thx

    Read the article

  • Make a Perl-style regex interpreter behave like a basic or extended regex interpreter

    - by Barry Brown
    I am writing a tool to help students learn regular expressions. I will probably be writing it in Java. The idea is this: the student types in a regular expression and the tool shows which parts of a text will get matched by the regex. Simple enough. But I want to support several different regex "flavors" such as: Basic regular expressions (think: grep) Extended regular expressions (think: egrep) A subset of Perl regular expressions, including the character classes \w, \s, etc. Sed-style regular expressions Java has the java.util.Regex class, but it supports only Perl-style regular expressions, which is a superset of the basic and extended REs. What I think I need is a way to take any given regular expression and escape the meta-characters that aren't part of a given flavor. Then I could give it to the Regex object and it would behave as if it was written for the selected RE interpreter. For example, given the following regex: ^\w+[0-9]{5}-(\d{4})?$ As a basic regular expression, it would be interpreted as: ^\\w\+[0-9]\{5\}-\(\\d\{4\}\)\?$ As an extended regular expression, it would be: ^\\w+[0-9]{5}-(\\d{4})?$ And as a Perl-style regex, it would be the same as the original expression. Is there a "regular expression for regular expressions" than I could run through a regex search-and-replace to quote the non-meta characters? What else could I do? Are there alternative Java classes I could use?

    Read the article

  • Recommendation for Regex editor?

    - by Tim
    I asked for recommendations for Regex editors on stackoverflow a while ago. Following is one of the replies: What is "good" depends on what is most useful to you. For me, though, these are the key features for a good regex editor (besides the ability to test and create regular expressions, of course, which is a prerequisite to be called a "regex editor" :-) : Displays matches hierarchically with captured groups. Explains/analyzes an entered regex in plain English, showing a hierarchical tree. Translates your regex into code for a language of your choice. RegexBuddy, as @Max mentioned, does all these but there is also a free alternative, Expresso that also does them very well. These two utilities are the only ones I have found with the crucial ability to explain a regex. The features sound very attractive to me. But later I found the two are for Windows. I tried to install Expresso, the free one, via Wine, but met some trouble, about which I asked in another post. So I was wondering if in Ubuntu there are some applications comparable to RegexBuddy and Expresso? If it is required to install .NET Framework in order to install Expresso, is it still worth to install Expresso on Ubuntu? Thanks and regards!

    Read the article

  • How to negate the whole regex?

    - by 01
    I have a regex, for example ([m]{2}|(t){1}). It matches ma and t and doesn't match bla. I want to negate the regex, thus it must match bla and not ma and t, by adding something to this regex. I know I can write bla, the actual regex is however more complex.

    Read the article

  • XSLT 1.0 grouping to reformat element defined by date into element defined by task

    - by Daniel
    Hi folks, I have a tricky XSLT transformation and I'd like your advise My xml is formatted as below: <Person> <name>John</name> <date>June12</date> <workTime taskID=1>34</workTime> <workTime taskID=2>12</workTime> </Person> <Person> <name>John</name> <date>June12</date> <workTime taskID=1>21</workTime> <workTime taskID=2>11</workTime> </Person> The output xml should be: <Person> <name>John</name> <taskID>1</taskID> <workTime> <date>June12</date> <time>34</time> </worTime> <workTime> <date>June13</date> <time>21</time> </worTime> </Person> <Person> <name>John</name> <taskID>2</taskID> <workTime> <date>June12</date> <time>12</time> </worTime> <workTime> <date>June13</date> <time>11</time> </worTime> </Person> Essentially, as an input, a "Person" object gathers all the task/workTime for a specific date. As an output, I want the "Person" object to gather the date/workTime for a specific task. I need to use XLST 1.0. I've been trying to use grouping with key but get very puzzled. Appreciate your help. Daniel

    Read the article

  • XSLT transformation by grouping based on 3 elements/attributes

    - by Daniel
    This question is related to http://stackoverflow.com/questions/2863202/xslt-1-0-grouping-to-reformat-element-defined-by-date-into-element-defined-by-tas Just to understand more clearly the trick behind. How would the XSLT look like if we were to group by date, task and shift as below: Input XML; <Person> <name>John</name> <date>June12</date> <shift tier=1> <workTime taskID=1>34</workTime> <workTime taskID=2>12</workTime> </shift> <shift tier=2> <workTime taskID=1>3</workTime> </shift> </Person> <Person> <name>John</name> <date>June13</date> <shift tier=1> <workTime taskID=1>21</workTime> <workTime taskID=2>11</workTime> </shift> <shift tier=2> <workTime taskID=1>2</workTime> </shift> </Person> and similarly, the output would be <Person> <name>John</name> <tier>1</tier> <taskID>1</taskID> <workTime> <date>June12</date> <time>34</time> </worTime> <workTime> <date>June13</date> <time>21</time> </worTime> </Person> <Person> <name>John</name> <tier>1</tier> <taskID>2</taskID> <workTime> <date>June12</date> <time>12</time> </worTime> <workTime> <date>June13</date> <time>11</time> </worTime> </Person> <Person> <name>John</name> <tier>2</tier> <taskID>1</taskID> <workTime> <date>June12</date> <time>3</time> </worTime> <workTime> <date>June13</date> <time>2</time> </worTime> </Person>

    Read the article

  • c# Regex trouble

    - by Shannow
    Hi there, I'm having a bit of trouble with my regex. String a = @"{target=}jump"; String b = "continue"; String c = "jump"; String d = @"{target=intro}jump"; String e = "prev"; String f = @"{target=}choice"; String g = @"{target=intro}choice"; String h = "choice"; String i = "previous"; String j = @"{target=intro}continue"; String k = "cont"; String l = @"{target=}continue"; Regex regex = new Regex(@"(^{target=(\w.*)}(choice|jump))|(^[^.]*(continue|previous))"); var a_res = regex.IsMatch(a); var b_res = regex.IsMatch(b); var c_res = regex.IsMatch(c); var d_res = regex.IsMatch(d); var e_res = regex.IsMatch(e); var f_res = regex.IsMatch(f); var g_res = regex.IsMatch(g); var h_res = regex.IsMatch(h); var i_res = regex.IsMatch(i); var j_res = regex.IsMatch(j); var k_res = regex.IsMatch(k); var l_res = regex.IsMatch(l); Basically what i need is to get a match when choice or jump is present that it is proceeded by {target= } with any number of characters after the =. And also to match if continue or previous are present but only if they are proceeded by nothing. so A = false, b = true, c = false, d = true, e = false, f = false, g = true, h = false, i = true, j = false, k = false and l = false, with my regex above I get correct reading for everything bar j and l. Can anyone please help?

    Read the article

  • Building a regex builder

    - by i.h4d35
    I am a beginner in programming in general and web development in particular. I am especially bad at regular expressions. Recently I was involved in building a couple of cPanel plugins(Perl-CGI) and that's when I realized how bad I am in regex. As a result, I have decided to build an online regex builder - this will help me to learn regex and help other struggling with regex. I have checked out GSkinner, Rubular and a couple of others like regexpal. It seemed to be a little difficult to use, hence i thought of writing another one. I do not know which tool is best suited for the job. should I write it in Perl or Python? My skill level is between beginner and intermediate in both those languages. What would be a good starting point - building it for the CLI or for the browser? I plan to get a string as an input, ask if the user want to search or search and replace, enter the search string (and the replace string where applicable) and then generate a regex. Would this be the right way to go?

    Read the article

  • how to negate whole regex ??

    - by 01
    I have regex (for example) ([m]{2}|(t){1}) and it matches ma and t and doesnt match bla I want it to match bla and doesnt match ma and t by adding something to this regex, i know i can write bla, my real-life regex is more complex.

    Read the article

  • Why is negation of a regex needed?

    - by Lazer
    There are so many questions on regex-negation here on SO. I am not sure I understand why people feel the need to negate a regex. Why not use something like grep -v that shows only the results that do not match the regex? $ ls april august december february january july june march may november october september $ ls | grep ber december november october september $ ls | grep -v ber april august february january july june march may

    Read the article

  • Regex to match a whole string only if it lacks a given substring/suffix

    - by Ivan Krechetov
    I've searched for questions like this, but all the cases I found were solved in a problem-specific manner, like using !g in vi to negate the regex matches, or matching other things, without a regex negation. Thus, I'm interested in a “pure” solution to this: Having a set of strings I need to filter them with a regular expression matcher so that it only leaves (matches) the strings lacking a given substring. For example, filtering out "Foo" in: Boo Foo Bar FooBar BooFooBar Baz Would result in: Boo Bar Baz I tried constructing it with negative look aheads/behinds (?!regex)/(?<!regex), but couldn't figure it out. Is that even possible?

    Read the article

  • Use RegEx in Java to extract parameters in between parentheses

    - by lars_bx
    I'm writing a utility to extract the names of header files from JSPs. I have no problem reading the JSPs line by line and finding the lines I need. I am having a problem extracting the specific text needed using regex. After looking at many similar questions I'm hitting a brick wall. An example of the String I'll be matching from within is: <jsp:include page="<%=Pages.getString(\"MY_HEADER\")%>" flush="true"></jsp:include> All I need is MY_HEADER for this example. Any time I have this tag: <%=Pages.getString I need what comes between this: <%=Pages.getString(\" and this: )%> Here is what I have currently (which is not working, I might add) : String currentLine; while ((currentLine = fileReader.readLine()) != null) { Pattern pattern = Pattern.compile("<%=Pages\\.getString\\(\\\\\"([^\\\\]*)"); Matcher matcher = pattern.matcher(currentLine); while(matcher.find()) { System.out.println(matcher.group(1).toString()); }} I need to be able to use the Java RegEx API and regex to extract those header names. Any help on this issue is greatly appreciated. Thanks! EDIT: Resolved this issue, thankfully. The tricky part was, after being given the right regex, it had to be taken into account that the String I was feeding to the regex was always going to have two " / " characters ( (/"MY_HEADER"/) ) that needed to be escaped in the pattern. Here is what worked (thanks to the help ;-)): Pattern pattern = Pattern.compile("<%=Pages\\.getString\\(\\\\\"([^\\\\\"]*)");

    Read the article

  • Boost Regex unknown number of var

    - by Katrin Thielmann
    I got a Problem with a regex expression and need help. I have some expressions like these in mein .txt File: 19 = NAND (1, 19) regex expression : http://rubular.com/r/U8rO09bvTO With this regex expression i got seperated matches for the numbers. But now I need a regex expression with a unknown size of numbers in the bracket . For example: 19 = NAND (1, 23, 13, 24) match1: 19 match2: 1 match3: 23 match4: 13 match5: 24 I don't know the number of the numbers. So i need a main expression for min 2 numbers in the bracket till a unknow number. I hope somebody can help me.

    Read the article

  • Regex to leave desired string remaining and others removed

    - by m7d
    In Ruby, what regex will strip out all but a desired string if present in the containing string? I know about /[^abc]/ for characters, but what about strings? Say I have the string "group=4&type_ids[]=2&type_ids[]=7&saved=1" and want to retain the pattern group=\d, if it is present in the string using only a regex? Currently, I am splitting on & and then doing a select with matching condition =~ /group=\d/ on the resulting enumerable collection. It works fine, but I'd like to know the regex to do this more directly.

    Read the article

  • Haskell: 'No instance for' arising from a trivial usage of Regex library

    - by artemave
    Following the (accepted) answer from this question, I am expecting the following to work: Prelude Text.Regex.Posix Text.Regex.Base.RegexLike Text.Regex.Posix.String> makeRegex ".*" (makeRegex is a shortcut for makeRegexOpts with predefined options) However, it doesn't: <interactive>:1:0: No instance for (RegexMaker regex compOpt execOpt [Char]) arising from a use of `makeRegex' at <interactive>:1:0-13 Possible fix: add an instance declaration for (RegexMaker regex compOpt execOpt [Char]) In the expression: makeRegex ".*" In the definition of `it': it = makeRegex ".*" Prelude Text.Regex.Posix Text.Regex.Base.RegexLike Text.Regex.Posix.String> make Regex ".*"::Regex <interactive>:1:0: No instance for (RegexMaker Regex compOpt execOpt [Char]) arising from a use of `makeRegex' at <interactive>:1:0-13 Possible fix: add an instance declaration for (RegexMaker Regex compOpt execOpt [Char]) In the expression: makeRegex ".*" :: Regex In the definition of `it': it = makeRegex ".*" :: Regex And I really don't understand why. EDIT Haskell Platform 2009.02.02 (GHC 6.10.4) on Windows EDIT2 Prelude Text.Regex.Base.RegexLike Text.Regex.Posix.String> :i RegexMaker class (RegexOptions regex compOpt execOpt) => RegexMaker regex compOpt execOpt source | regex -> compOpt execOpt, compOpt -> regex execOpt, execOpt -> regex compOpt where makeRegex :: source -> regex makeRegexOpts :: compOpt -> execOpt -> source -> regex makeRegexM :: (Monad m) => source -> m regex makeRegexOptsM :: (Monad m) => compOpt -> execOpt -> source -> m regex -- Defined in Text.Regex.Base.RegexLike

    Read the article

  • Javascript Regex multiple group matches in pattern

    - by mummybot
    I have a question for a Javascript regex ninja: How could I simplify my variable creation from a string using regex? I currently have it working without using any grouping, but I would love to see a better way! The string is: var url = 'resources/css/main.css?detect=#information{width:300px;}'; The code that works is: var styleStr = /[^=]+$/.exec(url).toString(); var id = /[^\#][^\{]+/.exec(styleStr).toString(); var property = /[^\{]+/.exec(/[^\#\w][^\:]+/.exec(styleStr)).toString(); var value = /[^\:]+/.exec(/[^\#\w\{][^\:]+[^\;\}]/.exec(styleStr)).toString(); This gives: alert(id) //information alert(property) //width alert(value) //300px Any takers?

    Read the article

  • OWASP Regex Repository: Is this regex correct?

    - by Jacco
    I was looking at the regular expression for validating various data types from the (OWASP Regex Repository). One of the regular expressions in there is called safetext and looks like: ^[a-zA-Z0-9\s.\-]+$ My first question is: Is this regular expression correct? complementary question If this Regex Repository any good at all?

    Read the article

  • Find multiple regex in each line and skip result if one of the regex doesn't match

    - by williamx
    I have a list of variables: variables = ['VariableA', 'VariableB','VariableC'] which I'm going to search for, line by line ifile = open("temp.txt",'r') d = {} match = zeros(len(variables)) for line in ifile: emptyCells=0 for i in range(len(variables)): regex = r'('+variables[i]+r')[:|=|\(](-?\d+(?:\.\d+)?)(?:\))?' pattern_variable = re.compile(regex) match[i] = re.findall(pattern_variable, line) if match[j] == []: emptyCells = emptyCells+1 if emptyCells == 0: for k, v in match[j]: d.setdefault(k, []).append(v) The requirement is that I will only keep the lines where all the regex'es matches! I want to collect all results for each variable in a dictionary where the variable name is the key, and the value becomes a list of all matches. The code provided is only what I've found out so far, and is not working perfectly yet...

    Read the article

  • C# regex. Optional match after string

    - by Oskar Kjellin
    I have an input like this test1.test2.part01 which I want to strip away to test1.test2. The only thing i know is that it will end with partxx and probably a dot before the partxx. However, it will not always be a apart. Another example of input might be testas1.tlp2.asd3.part10 which ofcourse should be stripped to testas1.tlp2.asd3. I've made all that, no problem. The problem is the dot at the end before partxx. My regex at the moment is: (.*).?part\d{1,2} But it will include the dot in the group. I do not want the dot to be in the group. The below works as I want it, given that the dot exists, but it will not always be there. (.*).part\d{1,2} How can I exclude the optional dot from the group?

    Read the article

  • Vim Regex to replace tags

    - by Rudiger Wolf
    I am lookin for a regex express to remove the email addresses from a text file. Input file: Hannah Churchman <[email protected]>; Julie Drew <[email protected]>; Output file: Hannah Churchman; Julie Drew; I thought a generic regex shuch as s/<(.*?)//g would be a good starting point but I am unable to find the right expression for use Vim? something like :%s/ <\(.*?\)>//g does not work. Error is "E486: Pattern not found:". :%s#[^ <]*>##g almost works but it leaves the space and < behind. :%s# <##g to remove the " <" remaining stuff. Any tips on how to better craft this command?

    Read the article

  • Complex(?) regex: Is expression, but not another

    - by Kieron
    (If you can make a better title, please do) Hi, I need to make sure a string matches the following regex: ^[0-9a-zA-Z]{1}[0-9a-zA-Z\.\-_]*$ (Starts with a letter or number, then any number of letters, numbers, dots, dashes or underscores) But given that, I need to make sure it doesn't match a Guid, my Guid matching reg-ex looks like this (obviously, this needs to be negated in the merged result): ^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$ The last requirement here is that they must (if it's possible) be merged into a single expression.

    Read the article

  • A pattern matching an expression that doesn't end with specific sequence

    - by patryk
    I need a regex pattern which matches such strings that DO NOT end with such a sequence: \.[A-z0-9]{2,} by which I mean the examined string must not have at its end a sequence of a dot and then two or more alphanumeric characters. For example, a string /home/patryk/www and also /home/patryk/www/ should match desired pattern and /home/patryk/images/DSC002.jpg should not. I suppose this has something to do with lookarounds (look aheads) but still I have no idea how to make it. Any help appreciated.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >