Search Results

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

Page 71/269 | < Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >

  • regex for matching strings that have illegal filename characters.

    - by cchampion
    I been trying to figure out how this blasted regex for two hours!!! It's midnight I gotta figure this out and go to bed!!! String str = new String("filename\\"); if(str.matches(".*[?/<>|*:\"{\\}].*")) { System.out.println("match"); }else { System.out.println("no match"); } ".*[?/<>|*:\"{\\}].*" is my regex expression. It catches everything correctly except the backslash!!! I need to know how to make it catch the backslash correctly please help! FYI, the illegal characters i'm trying to catch are ? \ / < | * : " I've got it working exception for the backslash

    Read the article

  • highlight query string in more than one field using solr search feature

    - by Romi
    i am using solr indexes for showing my search results. to show serch results i am parsing json data received from solr. i am able to highlight a query string in search result but only in a single field. for this i set hl=true and hl.fl="field1". i did it as $.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+lowerCaseQuery+"&hl=true&hl.fl=description,name&hl.usePhraseHighlighter=true&sort=price asc&json.wrf=?", function(result){ var n=result.response.numFound var highlight = new Array(n); $.each(result.highlighting, function(i, hitem){ var match = hitem.text[0].match(/<em>(.*?)<\/em>/); highlight[i]=match[1]; }); $.each(newresult.response.docs, function(i,item){ var word=highlight[item["UID_PK"]]; var result = item.text[0].replace(new RegExp(word,'g'), '<em>' + word + '</em>'); }); for this json object is as : { "responseHeader": { "status": 0, "QTime": 32 }, "response": { "numFound": 21, "start": 0, "docs": [ { "description": "The matte finish waves on this wedding band contrast with the high polish borders. This sharp and elegant design was finely crafted in Japan.", "UID_PK": "8252", }, { "description": "This elegant ring has an Akoya cultured pearl with a band of bezel-set round diamonds making it perfect for her to wear to work or the night out.", "UID_PK": "8142", }, ] }, "highlighting": { "8252": { "description": [ " and <em>elegant</em> design was finely crafted in Japan." ] }, "8142": { "description": [ "This <em>elegant</em> ring has an Akoya cultured pearl with a band of bezel-set round diamonds making" ] }, } } Now if i want to highlight query string in two fields i did as hl=true hl.fl=descrption, name my json is as: { "responseHeader":{ "status":0, "QTime":16 }, "response":{ "numFound":1904, "start":0, "docs":[ { "description":"", "UID_PK":"7780", "name":[ "Diamond bracelet with Milgrain Bezel1" ] }, { "description":"This pendant is sure to win hearts. Round diamonds form a simple and graceful line.", "UID_PK":"8121", "name":[ "Heartline Diamond Pendant" ] }, "highlighting":{ "7780":{ "name":[ "<em>Diamond</em> bracelet with Milgrain Bezel1" ] }, "8121":{ "description":[ "This pendant is sure to win hearts. Round <em>diamonds</em> form a simple and graceful line." ], "name":[ "Heartline <em>Diamond</em> Pendant" ] } } } Now how should i parse it to get the result. suggest me some general technique, so if i want to highlight query in more fields then i could do so. Thanks

    Read the article

  • Ajax routes in Rails 3

    - by Jatin
    In my Rails 2.3 application, the following routes were working properly map.ajax 'ajax', :controller => 'widgetresponse_controller' , :action => 'getWidgetJson' When I migrated to Rails 3, I tried a number of new routes, to get this working but none of them worked. 1. match 'ajax' => 'widgetresponse#getWidgetJson', :as => :ajax 2. match 'ajax' => 'widgetresponse_controller#getWidgetJson', :as => :ajax 3. get 'widgetresponse/getWidgetJson', :as => :ajax 4. get 'widgetresponse/getWidgetJson' Its a very basic question to ask, but I don't know what I am doing wrong.

    Read the article

  • Combine SQL statement

    - by ninumedia
    I have 3 tables (follows, postings, users) follows has 2 fields - profile_id , following_id postings has 3 fields - post_id, profile_id, content users has 3 fields - profile_id, first_name, last_name I have a follows.profile_id value of 1 that I want to match against. When I run the SQL statement below I get the 1st step in obtaining the correct data. However, I now want to match the postings.profile_id of this resulting set against the users table so each of the names (first and last name) are displayed as well for all the listed postings. Thank you for your help! :) Ex: SELECT * FROM follows JOIN postings ON follows.following_id = postings.profile_id WHERE follows.profile_id = 1

    Read the article

  • How to order results based on number of search term matches?

    - by Travis
    I am using the following tables in mysql to describe records that can have multiple searchtags associated with them: TABLE records ID title desc TABLE searchTags ID name TABLE recordSearchTags recordID searchTagID To SELECT records based on arbitrary search input, I have a statement that looks sort of like this: SELECT recordID FROM recordSearchTags LEFT JOIN searchTags ON recordSearchTags.searchTagID = searchTags.ID WHERE searchTags.name LIKE CONCAT('%','$search1','%') OR searchTags.name LIKE CONCAT('%','$search2','%') OR searchTags.name LIKE CONCAT('%','$search3','%') OR searchTags.name LIKE CONCAT('%','$search4','%'); I'd like to ORDER this resultset, so that rows that match with more search terms are displayed in front of rows that match with fewer search terms. For example, if a row matches all 4 search terms, it will be top of the list. A row that matches only 2 search terms will be somewhere in the middle. And a row that matches just one search term will be at the end. Any suggestions on what is the best way to do this? Thanks!

    Read the article

  • Lucene Analyzer to Use With Special Characters and Punctuation?

    - by Brandon
    I have a Lucene index that has several documents in it. Each document has multiple fields such as: Id Project Name Description The Id field will be a unique identifier such as a GUID, Project is a user's ProjectID and a user can only view documents for their project, and Name and Description contain text that can have special characters. When a user performs a search on the Name field, I want to be able to attempt to match the best I can such as: First Will return both: First.Last and First.Middle.Last Name can also be something like: Test (NameTest) Where, if a user types in 'Test', 'Name', or '(NameTest)', then they can find the result. However, if I say that Project is 'ProjectA' then that needs to be an exact match (case insensitive search). The same goes with the Id field. Which fields should I set up as Tokenized and which as Untokenized? Also, is there a good Analyzer I should consider to make this happen? I am stuck trying to decide the best route to implement the desired searching.

    Read the article

  • Stuck at being unable to print a substring no more than 4679 characters

    - by Newcoder
    I have a program that does string manipulation on very large strings (around 100K). The first step in my program is to cleanup the input string so that it only contains certain characters. Here is my method for this cleanup: public static String analyzeString (String input) { String output = null; output = input.replaceAll("[-+.^:,]",""); output = output.replaceAll("(\\r|\\n)", ""); output = output.toUpperCase(); output = output.replaceAll("[^XYZ]", ""); return output; } When i print my 'input' string of length 97498, it prints successfully. My output string after cleanup is of length 94788. I can print the size using output.length() but when I try to print this in Eclipse, output is empty and i can see in eclipse output console header. Since this is not my final program, so I ignored this and proceeded to next method that does pattern matching on this 'cleaned-up' string. Here is code for pattern matching: public static List<Integer> getIntervals(String input, String regex) { List<Integer> output = new ArrayList<Integer> (); // Do pattern matching Pattern p1 = Pattern.compile(regex); Matcher m1 = p1.matcher(input); // If match found while (m1.find()) { output.add(m1.start()); output.add(m1.end()); } return output; } Based on this program, i identify the start and end intervals of my pattern match as 12351 and 87314. I tried to print this match as output.substring(12351, 87314) and only get blank output. Numerous hit and trial runs resulted in the conclusion that biggest substring that i can print is of length 4679. If i try 4680, i again get blank input. My confusion is that if i was able to print original string (97498) length, why i couldnt print the cleaned-up string (length 94788) or the substring (length 4679). Is it due to regular expression implementation which may be causing some memory issues and my system is not able to handle that? I have 4GB installed memory.

    Read the article

  • Core Data fetch request with array

    - by JK
    I am trying to set a fetch request with a predicate to obtain records in the store whose identifiers attribute match an array of identifiers specified in the predicate e.g. NSString *predicateString = [NSString stringWithFormat:@"identifier IN %@", employeeIDsArray]; The employeeIDsArray contains a number of NSNumber objects that match IDs in the store. However, I get an error "Unable to parse the format string". This type of predicate works if it is used for filtering an array, but as mentioned, fails for a core data fetch. How should I set the predicate please?

    Read the article

  • acts-as-taggable-on: find tags with name LIKE, sort by tag_counts?

    - by James
    Hi I'm using the rails plugin acts-as-taggable-onand I'm trying to find the top 5 most used tags whose names match and partially match a given query. When I do User.skill_counts.order('count DESC').limit(5).where('name LIKE ?', params[:query]) This return the following error: ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: name: SELECT tags.*, COUNT(*) AS count FROM "tags" INNER JOIN users ON users.id = taggings.taggable_id LEFT OUTER JOIN taggings ON tags.id = taggings.tag_id AND taggings.context = 'skills' WHERE (taggings.taggable_type = 'User') AND (taggings.taggable_id IN(SELECT users.id FROM "users")) AND (name LIKE 'asd') GROUP BY tags.id, tags.name HAVING COUNT(*) > 0 ORDER BY count DESC LIMIT 5 But when I do User.skill_counts.first.name this returns "alliteration" I'd appreciate any help on this matter.

    Read the article

  • Xcode iphone sdk - Searching in UITableView, different pattern matching

    - by Lorenzo
    Hi everyone, I'm coding a UITableView with a UISearchBar to search between a list of cities (loaded in the uitableview) Here is my code for searhing: - (void) searchTableView { NSString *searchText = searchBar.text; NSMutableArray *searchArray = [[NSMutableArray alloc] init]; for (NSDictionary *dictionary in listOfItems) { NSArray *array = [dictionary objectForKey:@"Cities"]; [searchArray addObjectsFromArray:array]; } for (NSString *sTemp in searchArray) { NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch]; if (titleResultsRange.length > 0) [copyListOfItems addObject:sTemp]; } [searchArray release]; searchArray = nil;} And with this everything works fine, but i need to do something a bit different. I need to search only between items that match pattern Word* and not * Word *. For example if I search "roma", this need to match just with "Roma" or "Romania" and not with "Castelli di Roma". Is that possible with this searchbar? How can i modify this? Thanks

    Read the article

  • vb.net Is there a simple way to add a sound to a button click

    - by user867621
    Is there a simple way of doing this I found this online and I am getting an error Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _ (ByVal filename As String, ByVal snd_async As Long) As Long Function PlaySound(ByVal sWavFile As String) ' Purpose: Plays a sound. ' Argument: the full path and file name. If apisndPlaySound(sWavFile, 1) = 0 Then MsgBox("The Sound Did Not Play!") End If End Function A call to PInvoke function 'WindowsApplication3!WindowsApplication3.Module1::apisndPlaySound' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

    Read the article

  • Haskell type classes and type families (cont'd)

    - by Giuseppe Maggiore
    I need some help in figuring a compiler error which is really driving me nuts... I have the following type class: infixl 7 --> class Selectable a s b where type Res a s b :: * (-->) :: (CNum n) => (Reference s a) -> (n,(a->b),(a->b->a)) -> Res a s b which I instance twice. First time goes like a charm: instance Selectable a s b where type Res a s b = Reference s b (-->) (Reference get set) (_,read,write) = (Reference (\s -> let (v,s') = get s in (read v,s')) (\s -> \x -> let (v,s') = get s v' = write v x (_,s'') = set s' v' in (x,s''))) since the type checker infers (-->) :: Reference s a -> (n,a->b,a->b->a) -> Reference s b and this signature matches with the class signature for (--) since Res a s b = Reference s b Now I add a second instance and everything breaks: instance (Recursive a, Rec a ~ reca) => Selectable a s (Method reca b c) where type Res a s (Method reca b c) = b -> Reference s c (-->) (Reference get set) (_,read,write) = \(x :: b) -> from_constant( Constant(\(s :: s)-> let (v,s') = get s :: (a,s) m = read v ry = m x :: Reference (reca) c (y,v') = getter ry (cons v) :: (c,reca) v'' = elim v' (_,s'') = set s' v'' in (y,s''))) :: Reference s c the compiler complains that Couldn't match expected type `Res a s (Method reca b c)' against inferred type `b -> Reference s c' The lambda expression `\ (x :: b) -> ...' has one argument, which does not match its type In the expression: \ (x :: b) -> from_constant (Constant (\ (s :: s) -> let ... in ...)) :: Reference s c In the definition of `-->': --> (Reference get set) (_, read, write) = \ (x :: b) -> from_constant (Constant (\ (s :: s) -> ...)) :: Reference s c reading carefully the compiler is telling me that it has inferred the type of (--) thusly: (-->) :: Reference s a -> (n,a->(Method reca b c),a->(Method reca b c)->a) -> (b -> Reference s c) which is correct since Res a s (Method reca b c) = b -> Reference s c but why can't it match the two definitions? Sorry for not offering a more succint and standalone example, but in this case I cannot figure how to do it...

    Read the article

  • Wordpress database query running slow - one of the columns doesn't exist!

    - by Pavel
    Hi there. I'm having some problems with the query that wordpress runs. That's the one: SELECT DISTINCT ID,post_title,post_date,post_content,MATCH(post_title,post_content) AGAINST ('S') AS score FROM wp_posts WHERE MATCH (post_title,post_content) AGAINST ('S') AND post_date <= 'S' AND post_status = 'S' AND id != N AND post_type = 'S' ORDER BY score DESC When I'm running this query in phpmyadmin it says that N column doesn't exist so clause "AND id != N" si not making any sense. I ran the query again without this clause and db behaved like fully optimized one. Please can someone give me a hint on that? My questions are: What this clause is used for? What wordpress is trying to find by running this and Can I modify core wordpress files to get rid of this clause? Any response or help greatly appreciated!!

    Read the article

  • Regex Question..

    - by Josh
    Hello everyone- In my C# Console App I'm trying to use Regex to search a string to determine if there is a match or not. Below is my code but it is not quite working right so I will explain further. sSearchString is set to "_One-Call_Pipeline_Locations" and pDS.Name is a filename it is searching against. Using the code below it is set to true for Nevada_One-Call_Pipeline_Locations and Nevada_One-Call_Pipeline_LocationsMAXIMUM. There should be a match for Nevada_One-Call_Pipeline_Locations But Not for Nevada_One-Call_Pipeline_LocationsMAXIMUM. How can I change my code to do this properly? Thanks in advance if (Regex.IsMatch(pDS.Name, sSearchString))

    Read the article

  • Rails 3 routes and using GET to create clean URLs?

    - by Hard-Boiled Wonderland
    I am a little confused with the routes in Rails 3 as I am just starting to learn the language. I have a form generated here: <%= form_tag towns_path, :method => "get" do %> <%= label_tag :name, "Search for:" %> <%= text_field_tag :name, params[:name] %> <%= submit_tag "Search" %> <% end %> Then in my routes: get "towns/autocomplete_town_name" get "home/autocomplete_town_name" match 'towns' => 'towns#index' match 'towns/:name' => 'towns#index' resources :towns, :module => "town" resources :businesses, :module => "business" root :to => "home#index" So why when submitting the form do I get the URL: /towns?utf8=?&name=townname&commit=Search So the question is how do I make that url into a clean url like: /towns/townname Thanks, Andrew

    Read the article

  • get entire line with java.util.scanner.hasNext(regex)

    - by Hussain
    I'm doing something in Java that requires input to be matched against the pattern ^[1-5]$. I should have a while loop looping through each line of input, checking it against the pattern, and outputting an error message if it does not. Sudo code: while (regex_match(/^[^1-5]$/,inputLine)) { print ("Please enter a number between 1 and 5! "); getNextInputLine(); } I can use java.util.Scanner.hasMatch("^[^1-5]$"), but that will only match a single token, not the entire line. Any idea on how to make hasMatch match against the entire line? (Setting the delimiter to "\n" or "\0" doesn't work.)

    Read the article

  • PHP Captcha without session

    - by Anton N
    Ok, here is an issue: in the project i'm working on, we can't rely on server-side sessions for any functionality. The problem is that common captcha solutions from preventing robotic submits require session to store the string to match captcha against. The question is - is there any way to solve the problem without using sessions? What comes to my mind - is serving hidden form field, containing some hash, along with captcha input field, so that server then can match these two values together. But how can we make this method secure, so that it couldn't be used to break captcha easily.

    Read the article

  • Access 2007: Dynamic SQL to be run when opening a report

    - by blockcipher
    I'm trying to have some SQL execute when I open a report. This works fine when I try to match on a column that's an integer with an integer, but when I try to match on a "text" column, it keeps popping up a dialog asking for what you want to filter on. Here's a somple query: select person_phone_numbers.person_id from person_phone_numbers where phone_number = '444-444-4444' This is actually a sub-query I'm trying to use, but this is where the problem is. If I change it to this it works fine: select person_phone_numbers.person_id from person_phone_numbers where phone_id = 2 I put this in the OnOpen event and I'm assigning it to Me.RecordSource if that makes a difference. My goal here is to have a form accept query parameter(s) and have it open a report with the results. Any thoughts on why it wants to ask for a parameter vs. just running the query the way I have it?

    Read the article

  • Help with Regex statement in Ruby

    - by user336777
    I have a string called 'raw'. I am trying to parse it in ruby in the following way: raw = "HbA1C ranging 8.0—10.0%" raw.scan /\d*.?\d+[ ](-+|\342\200\224)[ ]\d*.?\d+/ The output from the above is []. I think it should be: ["8.0—10.0"]. Does anyone have any insight into what is wrong with the above regex statement? Note: \342\200\224 is equal to '—'. The piece that is not working is: (-+|\342\200\224) I think it should be equivalent to saying, match on 1 or more '-' OR match on the string \342\200\224. Any help would be greatly appreciated it!

    Read the article

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

    - 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? $query = "SELECT * WHERE story_time > time()-86400 AND MATCH (story_title) AGAINST ('".validate_input($_GET['q'])."' IN BOOLEAN MODE) AS Relevance FROM ".$config['db']['pre']."stories WHERE MATCH (story_title) AGAINST ('+".validate_input($_GET['q'])."' IN BOOLEAN MODE) HAVING Relevance > 0.2 ORDER BY Relevance DESC, story_time DESC LIMIT ".validate_input(($_GET['page']-1)*10).",10";

    Read the article

  • Strange sql query result from Mysql and from PHP mysqli_query!

    - by qinHaiXiang
    this is the query command echo from php web page: SELECT DISTINCT FT.file_type_name AS type,FT.file_type_en AS tp,FT.file_type_id AS fti, MATCH(keywords) AGAINST ('words <2' IN BOOLEAN MODE ) AS score FROM movie AS M,file_type AS FT WHERE MATCH (keywords) AGAINST ('words <2' IN BOOLEAN MODE ) AND M.type_cn = FT.file_type_id HAVING score >=1 ORDER BY FT.file_type_order; I am running above query in MySQL tools HeidiSQL and got only tow row records which score are 1.66666 and 2. If I remove the HAVING clause I would got three row records with one's score less than 1. But the same query I get from PHP mysqli_query() were all the three records and the one which score less than 1 became 1. What is the problem. Any tips will be pleasure. Thank you very much!!

    Read the article

  • emacs: how do I use edebug on code that is defined in a macro?

    - by Cheeso
    I don't even know the proper terminology for this lisp syntax, so I don't know if the words I'm using to ask the question, make sense. But the question makes sense, I'm sure. So let me just show you. cc-mode (cc-fonts.el) has things called "matchers" which are bits of code that run to decide how to fontify a region of code. That sounds simple enough, but the matcher code is in a form I don't completely understand, with babckticks and comma-atsign and just comma and so on, and furthermore it is embedded in a c-lang-defcost, which itself is a macro. And I want to run edebug on that code. Look: (c-lang-defconst c-basic-matchers-after "Font lock matchers for various things that should be fontified after generic casts and declarations are fontified. Used on level 2 and higher." t `(;; Fontify the identifiers inside enum lists. (The enum type ;; name is handled by `c-simple-decl-matchers' or ;; `c-complex-decl-matchers' below. ,@(when (c-lang-const c-brace-id-list-kwds) `((,(c-make-font-lock-search-function (concat "\\<\\(" (c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds)) "\\)\\>" ;; Disallow various common punctuation chars that can't come ;; before the '{' of the enum list, to avoid searching too far. "[^\]\[{}();,/#=]*" "{") '((c-font-lock-declarators limit t nil) (save-match-data (goto-char (match-end 0)) (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start) (c-forward-syntactic-ws)) (goto-char (match-end 0))))))) I am reading up on lisp syntax to figure out what those things are and what to call them, but aside from that, how can I run edebug on the code that follows the comment that reads ;; Fontify the identifiers inside enum lists. ? I know how to run edebug on a defun - just invoke edebug-defun within the function's definition, and off I go. Is there a corresponding thing I need to do to edebug the cc-mode matcher code forms?

    Read the article

  • scrollTo (jQuery) won't work in firefox

    - by William
    For some reason, firefox seems to ignore my scrollTo function even though it works in chrome and safari. Here's an example link: http://blog.rainbird.me/post/2358248459/blowholes-are-awesome Chrome and Safari will automatically scroll to the top of the image (with an offset of 20 pixels) It doesn't work in firefox. I'm baffled! code: $(document).ready(function() { $(".photoShell img").lazyload({ placeholder: "http://william.rainbird.me/boston-polaroid/white.gif", threshold: 200 }); window.viewport = { height: function() { return $(window).height(); }, width: function() { return $(window).width(); }, scrollTop: function() { return $(window).scrollTop(); }, scrollLeft: function() { return $(window).scrollLeft(); } }; $(".photoShell img").hide(); $(".photoShell .caption").hide(); $(".photoShell img").load(function() { var maxWidth = viewport.width() - 40; // Max width for the image if(maxWidth > 960){ maxWidth = 960; } var maxHeight = viewport.height() - 50; // Max height for the image var ratio = 0; // Used for aspect ratio var width = $(this).width(); // Current image width var height = $(this).height(); // Current image height // Check if the current width is larger than the max if(width > maxWidth){ ratio = maxWidth / width; // get ratio for scaling image $(this).css("width", maxWidth); // Set new width $(this).css("height", height * ratio); // Scale height based on ratio height = height * ratio; // Reset height to match scaled image width = width * ratio; // Reset width to match scaled image } // Check if current height is larger than max if(height > maxHeight){ ratio = maxHeight / height; // get ratio for scaling image $(this).css("height", maxHeight); // Set new height $(this).css("width", width * ratio); // Scale width based on ratio width = width * ratio; // Reset width to match scaled image } $(this).parents('div.photoShell').css("width", $(this).width() + 22); $(this).parents('div.photoShell').addClass('loaded'); $(this).next(".caption").show(); var scrollNum = $(this).parents('div.photoShell').offset().top; $.scrollTo(scrollNum - 20, {duration: 700, axis:"y"}); $(this).fadeIn("slow"); }).each(function() { // trigger the load event in case the image has been cached by the browser if(this.complete) $(this).trigger('load'); });

    Read the article

< Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >