Search Results

Search found 6715 results on 269 pages for 'preg match'.

Page 59/269 | < Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >

  • Perl: Compare and edit underlying structure in hash

    - by Mahfuzur Rahman Pallab
    I have a hash of complex structure and I want to perform a search and replace. The first hash is like the following: $VAR1 = { abc => { 123 => ["xx", "yy", "zy"], 456 => ["ab", "cd", "ef"] }, def => { 659 => ["wx", "yg", "kl"], 456 => ["as", "sd", "df"] }, mno => { 987 => ["lk", "dm", "sd"] }, } and I want to iteratively search for all '123'/'456' elements, and if a match is found, I need to do a comparison of the sublayer, i.e. of ['ab','cd','ef'] and ['as','sd','df'] and in this case, keep only the one with ['ab','cd','ef']. So the output will be as follows: $VAR1 = { abc => { 123 => ["xx", "yy", "zy"], 456 => ["ab", "cd", "ef"] }, def => { 659 => ["wx", "yg", "kl"] }, mno => { 987 => ["lk", "dm", "sd"] }, } So the deletion is based on the substructure, and not index. How can it be done? Thanks for the help!! Lets assume that I will declare the values to be kept, i.e. I will keep 456 = ["ab", "cd", "ef"] based on a predeclared value of ["ab", "cd", "ef"] and delete any other instance of 456 anywhere else. The search has to be for every key. so the code will go through the hash, first taking 123 = ["xx", "yy", "zy"] and compare it against itself throughout the rest of the hash, if no match is found, do nothing. If a match is found, like in the case of 456 = ["ab", "cd", "ef"], it will compare the two, and as I have said that in case of a match the one with ["ab", "cd", "ef"] would be kept, it will keep 456 = ["ab", "cd", "ef"] and discard any other instances of 456 anywhere else in the hash, i.e. it will delete 456 = ["as", "sd", "df"] in this case.

    Read the article

  • php Dollar amount Regular Expression

    - by Thildemar
    I am have completed javascript validation of a form using Regular Expressions and am now working on redundant verification server-side using PHP. I have copied this regular expression from my jscript code that finds dollar values, and reformed it to a PHP friendly format: /\$?((\d{1,3}(,\d{3})*)|(\d+))(\.\d{2})?$/ Specifically: if (preg_match("/\$?((\d{1,3}(,\d{3})*)|(\d+))(\.\d{2})?$/", $_POST["cost"])){} While the expression works great in javascript I get : Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 1 when I run it in PHP. Anyone have a clue why this error is coming up?

    Read the article

  • finding and returning a string with a specified prefix

    - by tipu
    I am close but I am not sure what to do with the restuling match object. If I do p = re.search('[/@.* /]', str) I'll get any words that start with @ and end up with a space. This is what I want. However this returns a Match object that I dont' know what to do with. What's the most computationally efficient way of finding and returning a string which is prefixed with a @? For example, "Hi there @guy" After doing the proper calculations, I would be returned guy

    Read the article

  • Accessing parent-level controls from inside a ComboBox's child controls

    - by eponymous23
    I have XAML similar to this: <ListBox ItemsSource="{Binding SearchCriteria, Source={StaticResource model}}" SelectionChanged="cboSearchCriterionType_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Name="spCriterion" Orientation="Horizontal" Height="20"> <ComboBox Name="cboSearchCriterionType" Width="120" SelectionChanged="cboSearchCriterionType_SelectionChanged"> <ComboBox.Items> <ComboBoxItem IsSelected="True" Content="Anagram Match" /> <ComboBoxItem Content="Pattern Match" /> <ComboBoxItem Content="Subanagram Match" /> <ComboBoxItem Content="Length" /> <ComboBoxItem Content="Number of Vowels" /> <ComboBoxItem Content="Number of Anagrams" /> <ComboBoxItem Content="Number of Unique Letters" /> </ComboBox.Items> </ComboBox> <TextBox x:Name="SearchSpec" Text="{Binding SearchSpec}" /> <TextBox x:Name="MinValue" Text="{Binding MinValue}" Visibility="Collapsed" /> <TextBox x:Name="MaxValue" Text="{Binding MaxValue}" Visibility="Collapsed" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> As you can tell from the markup, I have a listbox that is bound to a collection of SearchCriterion objects (collectively contained in a SearchCriteria object). The idea is that the user can add/remove criterion items from the criteria, each criterion is represented by a listbox item. Inside the listbox item I have a combobox and three textboxes. What I'm trying to do is change the visibility of the TextBox controls depending on the item that is selected in the ComboBox. For example, if the user selects "Pattern Match" then I want to show only the first textbox and hide the latter two; conversely, if the user selects "Length" or any of the "Number of..." items, then I want to hide the first TextBox and show the latter two. What is the best way to achieve this? I was hoping to do something simple in the SelectionChanged event handler for the listbox but the textbox controls are presumably out of the SelectionChanged event's scope. Do I have to programmatically traverse the control hierarchy and find the controls?

    Read the article

  • Weird error using preg_match and unicode

    - by Thorpe Obazee
    if (preg_match('(\p{Nd}{4}/\p{Nd}{2}/\p{Nd}{2}/\p{L}+)', '2010/02/14/this-is-something')) { // do stuff } The above code works. However this one doesn't. if (preg_match('/\p{Nd}{4}/\p{Nd}{2}/\p{Nd}{2}/\p{L}+/u', '2010/02/14/this-is-something')) { // do stuff } Maybe someone could shed some light as to why the one below doesn't work. This is the error that is being produced: A PHP Error was encountered Severity: Warning Message: preg_match() [function.preg-match]: Unknown modifier '\'

    Read the article

  • Search backward through a string using a regex (in Python)?

    - by John Mulder
    I'm parsing some code and want to match the doxygen comments before a function. However, because I want to match for a specific function name, getting only the immediately previous comment is giving me problems. Is there a way to search backward through a string using the Python Regex library? Is there a better (easier) approach that I'm missing?

    Read the article

  • Help mod_rewrite to Zeus

    - by FFish
    I just found out my host is on ZEUS.. Please can somebody help me with my rewrites: domain.com/001234 redirects to domain.com/001234-some-keywords.html Apache: RewriteRule ^([0-9]{6}+)/?$ includes/redirect.php?ref=$1 [L] RewriteRule ^([0-9]{6})-.*?\.html$ templates/default/index.php?ref=$1 [L] tried this in Zeus: match URL into $ with ^([0-9]{6}+)/?$ if matched then set URL = includes/redirect.php?ref=$1 endif match URL into $ with ^id/([0-9]+)/?$ if matched then set URL = home/content.php?id=$1 endif

    Read the article

  • Obj-C crashes on substringWithRange message

    - by code_burgar
    The following code is making my app crash at line 3 without an error I would recognize or know how to deal with. Any ideas as to what I am doing wrong? NSInteger *match = [str1 intValue] + [str2 intValue]; NSString *strrep = [NSString stringWithFormat:@"%i", match]; label.text = [strrep substringWithRange:NSMakeRange(1,3)];

    Read the article

  • Using a regex pattern to find revision numbers from a svn merge

    - by zyzy
    svn diff -rXX:HEAD Will give me a format like this, if there has been a merge between those revisions: Merged /<branch>:rXXX,XXX-XXX or Merged /<branch>:rXXX I'm not very familiar with regex and am trying to put together a pattern which will match all the numbers (merged revision numbers) AFTER matching the "Merged /branch:r" part. So far I have this to match the first part: [Mm]erged.*[a-zA-Z]:r Thanks in adv. for the help :)

    Read the article

  • help for splitting a string in javascript

    - by Hero
    Hi everyone... I'd asked a question about the splitting the a string like below: Input string: "a=aa| b=b||b | c=cc" and the output: a=aa b=b||b c=cc Kobi's answer was: var matches = "a=aa|b=b||b|c=cc".match(/(?:[^|]|\|\|)+/g) his answer was correct. But I need to use "split" method and save store the outputs in a array. so I can't use the Match Method. So please help me...

    Read the article

  • MySQL - How do I insert an additional where clause into this full-text search (updated)

    - by Steven
    I want to add a WHERE clause to a full text search query (to limit to past 24 hours), but wherever I insert it I get Low Level Error. Is it possible to add the clause and if so, how? Here is the code WITHOUT the where clause: $query = "SELECT *, MATCH (story_title) AGAINST ('$query' IN BOOLEAN MODE) AS Relevance FROM stories WHERE MATCH (story_title) AGAINST ('+$query' IN BOOLEAN MODE) HAVING Relevance > 0.2 ORDER BY Relevance DESC, story_time DESC;

    Read the article

  • Specifying Entire Path As Optional Rails 3.0.0

    - by Kevin Sylvestre
    I want to create a Rails 3 route with entirely optional parameters. The example route is: match '(/name/:name)(/height/:height)(/weight/:weight)' => 'people#index' The route works if I specify it as: match '/people(/name/:name)(/height/:height)(/weight/:weight)' => 'people#index' But I want to have this as the root URL. Thanks.

    Read the article

  • How do you make a regular expression that matches a word with one randomly inserted character?

    - by Dfowj
    Hey all, i want to use a regular expression to match a word with one specified character randomly placed within it. I also want to keep that 'base' word's characters in their original order. For example, with the 'base' word of test and the specified character of 'y', i want the regular expression to match all the following, and ONLY the following: ytest, tyest, teyst, tesyt, testy Incase it matters, im working in javascript and using the dojo toolkit. Thanks!

    Read the article

  • Using RE to retrive an ID

    - by chrissygormley
    Hello, I am trying to use RE to match a changing ID and extract it. I am having some bother getting it working. The String is: m = 'Some Text That exists version 1.0.41.476 Fri Jun 4 16:50:56 EDT 2010' The code I have tried so far is: r = re.compile(r'(s*\s*)(\S+)') m = m.match(r) Can anyone help extract this string. Thanks

    Read the article

  • Javascript simple regexp doesn't work

    - by bah
    Hi, I have this code, it looks alright and is really basic, but i can't make it work: function checkValid(elem){ var abc = elem.value; var re = "/[0-9]/"; var match = re.test(abc); alert(match); } It matches 0 and 9, but not 1 to 8, what's wrong here? Thanks.

    Read the article

  • Compare string with all values in array

    - by Hallik
    I am trying to fumble through python, and learn the best way to do things. I have a string where I am doing a compare with another string to see if there is a match: if paid[j].find(d)>=0: #BLAH BLAH If 'd' were an array, what is the most efficient way to see if the string contained in paid[j] has a match to any value in 'd'?

    Read the article

  • What is wrong with this PHP function.

    - by [email protected]
    I am new to PHP and regular expression. I was going thorugh some online examples and came with this example: <?php echo preg_replace_callback('~-([a-z])~', function ($match) { return strtoupper($match[1]); }, 'hello-world'); // outputs helloWorld ?> in php.net but to my surprise it does not work and keep getting error: PHP Parse error: parse error, unexpected T_FUNCTION Why get error ?

    Read the article

  • How to combine these three sql queries into one?

    - by lam3r4370
    How to combine these two sql queries into one? SELECT DISTINCT * FROM rss WHERE MATCH(content,title) AGAINST ('$filter') SELECT COUNT(content) FROM rss WHERE MATCH(content,title) AGAINST ('$filters') And if the result is 0 from the above query - SELECT DISTINCT * FROM rss WHERE content LIKE '%$filters%' OR title LIKE '%$filters%'; $filter .= $row['filter']; $filters = $row['filter']; $filters may be more than one keyword

    Read the article

  • Can't get jQuery to get focus on cloned input fields

    - by Rebel1Moon
    I have a page that needs to create dynamic form fields as often as the user needs, and I am trying to use Ajax to tie it in to my database for faster form entry and to prevent user typos. So, I have put my Ajax returned data into popup div, the user selects, then the form field is filled in. The problem comes on the cloned fields. They don't seem to want to bring up the popup div when focused. I am thinking it is something to do with when they get created/added to the DOM. Here is my JS that creates the clones: $(document).ready(function() { var regex = /^(.*)(\d)+$/i; var cloneIndex = $(".clonedInput").length; $("button.clone").live("click", function(){ $(this).parents(".clonedInput").clone() .appendTo("#course_container") .attr("id", "clonedInput" + cloneIndex) .find("*").each(function() { var id = this.id || ""; var match = id.match(regex) || []; if (match.length == 3) { this.id = match[1] + (cloneIndex); } }); cloneIndex++; numClones=cloneIndex-1; //alert("numClones "+numClones); }); Here is where I expect to be able to get focus on the correct cloned field and call the popup. The baker_equiv0 id is original code, whereas baker_equiv1 is the first clone. $('#baker_equiv0').focus(function() { \\ THIS CODE WORKS $('.popup').fadeIn(500); $('#results').empty(); // document.enter_data.baker_equiv1.value="test"; THIS LINE WORKS //alert("numClones "+numClones); }); $('#baker_equiv1').focus(function() { // THIS DOESN'T EVER FIRE alert("numClones "+numClones); $('.popup').fadeIn(500); $('#results').empty(); }); Here is the HTML with the form: <label for="baker_equiv" class="">Baker Equivalent: <span class="requiredField">*</span></label> <input type="text" class="cinputsa" name="baker_equiv[]" id="baker_equiv0" size="8" ONKEYUP="get_equiv(this.value);"> If I put this in the HTML code above, it works fine: onfocus="alert(this.id)" I'd also be interested in how to adjust the JS code to work based on the id array created rather than having to copy code for each potential set of fields clones, i.e., baker_equiv[] rather than baker_equiv0, baker_equiv1, etc. Thanks all!

    Read the article

  • document.URL Matching in Javascript

    - by streetparade
    I have a url which looks like this https://test.high.com/people/11111111-name-firstname-_custa/deals/new Now i need to match document.URL if im on that Page if so i will alert a message. The important part is /deals/new How can i match that in Javascript?

    Read the article

  • Looking to clean up a small ruby script.

    - by Badweather
    I'm looking for a much more idiomatic way to do the following little ruby script. File.open("channels.xml").each do |line| if line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)') puts line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)') end end Thanks in advance for any suggestions.

    Read the article

< Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >