Search Results

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

Page 172/269 | < Previous Page | 168 169 170 171 172 173 174 175 176 177 178 179  | Next Page >

  • ANTRL: token to text in rewrite rule

    - by Antonio
    I'm building an AST using ANTLR. I want to write a production that match a this string: ${identifier} so, in my grammar file I have: reference : DOLLAR LBRACE IDENT RBRACE -> ^(NODE_VAR_REFERENCE IDENT) ; This works fine. I'm using my own adaptor to emit tree nodes. The rewrite rule used creates for me two nodes: one for NODE_VAR_REFERENCE and one for IDENT. What I want to do is create only one node (for NODE_VAR_REFERENCE token) and this node must have the IDENT token in his "token" field. Is this possible using a rewrite rule? Thanks.

    Read the article

  • Regular Expression: Changes HTML Attributes Value to some pattern

    - by brain90
    Dear Engineers, I'm a newbie in RegEx I have thousands html tags, have wrote like this: <input type="text" name="CustomerName" /> <input type="text" name="SalesOrder"/> I need to match every name attribute values and convert them all to be like this: CustomerName -> cust[customer_name] SalesOrder -> cust[sales_order] So the results will be : <input type="text" name="cust[customer_name]" /> <input type="text" name="cust[sales_order]" /> My best try have stuck in this pattern: name=\"[a-zA-Z0-9]*\" - just found name="CustomerName" Please guide me wrote some Regular Expression magics to done this, I'm using Netbeans PDT. Thanks in advance for any pointers!.

    Read the article

  • How to get attributes values separately for each container present on the webpage in jquery ?

    - by Rachel
    This question is in continuation to How to get attributes of container in jquer, I have different containers on my webpage and all of them have <div id = "some values"> now how can I get attributes values separately for each component ? Is there any way I can know which attribute id belong to which container div ? Currently I am using : var id = $( '.promotion' ).attr( 'id' ); But if I have multiple promotional components on page and all have same div attribute as id than how can I relate that this particular attribute id belonged to this specific container ? Update: I am having a function which is called for each container present on the page and so if I am using above mentioned code than will it not always return me the first match for id in the div and would never go to other divs and so I will always get same value for id which is for the first container ? If so than what is the work around for this ? Hope this question is clear.

    Read the article

  • Is it possible to write a Java printf statement that prints the statement itself?

    - by polygenelubricants
    Is it possible to have a Java printf statement, whose output is the statement itself? Some snippet to illustrate: // attempt #1 public class Main { public static void main(String[] args) { System.out.printf("something"); } } This prints something. So the output of attempt #1 is not quite exactly the printf statement in attempt #1. We can try something like this: // attempt #2 public class Main { public static void main(String[] args) { System.out.printf("System.out.printf(\"something\");"); } } And now the output is System.out.printf("something"); So now the output of attempt #2 matches the statement in output #1, but we're back to the problem we had before, since we need the output of attempt #2 to match the statement in attempt #2. So is it possible to write a one-line printf statement that prints itself?

    Read the article

  • Is it good practice to initialize array in C/C++?

    - by sand
    I recently encountered a case where I need to compare two files (golden and expected) for verification of test results and even though the data written to both the files were same, the files does not match. On further investigation, I found that there is a structure which contains some integers and a char array of 64 bytes, and not all the bytes of char array were getting used in most of the cases and unused fields from the array contain random data and that was causing the mismatch. This brought me ask the question whether it is good practice to initialize the array in C/C++ as well, as it is done in Java?

    Read the article

  • What are the common patterns in web programming?

    - by lankerisms
    I have been trying to write my first big web app (more than one cgi file) and as I kept moving forward with the rough prototype, paralelly trying to predict more tasks, this is the todo that got accumulated (In no particular order). * Validations and input sanitizations * Object versioning (to avoid edit conflicts. I dont want hard locks) * Exception handling * memcache * xss and injection protections * javascript * html * ACLs * phonetics in search, match and find duplicates (for form validation) * Ajaxify!!! (I have snipped off the project specific items.) I know that each todo will be quite tied up to its project and technologies used. What I am wondering though, is if there is a pattern in your todo items as well as the sequence in which you experienced guys have come across them.

    Read the article

  • how do i keep the aspect ratio on image buttons in android?

    - by clayton33
    i have 5 square ImageButtons that i want to have lined up side by side on the bottom of the screen. I have each one set (different id's) as: <ImageButton android:id="@+id/box1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:adjustViewBounds="true" android:scaleType="fitXY" android:layout_weight="1" android:layout_margin="1dp" /> and i have the background assigned in main java like this: int[] imageIds = new int[] {R.id.box1,R.id.box2,R.id.box3,R.id.box4,R.id.box5}; for(int i = 0; i<5; i++){ imageButtons[i] = (ImageButton) findViewById(imageIds[i]); imageButtons[i].setBackgroundResource(R.drawable.blank); } what i would like to have it do is scale the width to fit neatly side-by-side at the bottom of the screen (which it does now ok), but have the height automatically scale to match the width as well. is this possible? i don't want to use setImageSource because then it puts a border around the imagebutton.

    Read the article

  • Storing/Quering multiple value in SQLite

    - by chmod
    I'm trying to store a blooming season in month for each tree in SQLite3. Currently I had the field "month" then I store the month name in the field. For example Tree Name Month Tree1 Jan,Feb,Mar Tree2 Nov,Dec,Jan Tree3 Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec Tree4 Mar,Apr,Nov,Dec Tree5 Jan,Feb,Mar,Apr I'm not sure if this is the best way to store it, Any recommendation is appreciate. Secondly, I need to perform a query where I enter in the month and it should return me the tree name that match the search criteria. For example If I search for "Jan" the result should be Tree1,Tree2,Tree3,Tree5 "Jan,Feb,Mar" the result should be Tree1,Tree3,Tree5 "Jan,Feb,Mar,Apr" the result should be Tree5 "Sep,Oct,Nov,Dec" the result should be none Which SQL query do I have to use in order to obtain the above result? Thanks

    Read the article

  • How can I setup Eclipse for better Android Widget development?

    - by MBonig
    I'm trying to develop a widget for Android. I'm using Eclipse but I can't get the view editor setup to match what I'm going to see when I deploy to my phone. I'm creating a 4x1 widget. I've gone through and tried setting up a new "Device" so that I can preview what the widget will look like before I deploy. I said the device is landscape, setup a 240dpi for the x and y on the device and set the dimensions to 294x72 (also tried 72x294 but that didn't work any better). I've done some googling and I can't seem to find any guides for setting up Eclipse. Any help is greatly appreciated. Thanks

    Read the article

  • Sign application with several certificates

    - by tschiggerl
    Hi, From the signing documentation at http://developer.android.com/intl/zh-TW/guide/publishing/app-signing.html: When the system is installing an update to an application, if any of the certificates in the new version match any of the certificates in the old version, then the system allows the update. This indicates that an application can be signed with multiple certificates. This is an interesting option to allow multiple entities to sign an application. e.g: A system application which was initially signed by the device's manufacturer. Further updates could be signed by the developer. Am I misreading the documentation or is this really possible? If so, how? Is there any other way for an application to support different certificates and with that, having two or more entities sign it? Thanks, Rúben

    Read the article

  • Efficient way to combine results of two database queries.

    - by ensnare
    I have two tables on different servers, and I'd like some help finding an efficient way to combine and match the datasets. Here's an example: From server 1, which holds our stories, I perform a query like: query = """SELECT author_id, title, text FROM stories ORDER BY timestamp_created DESC LIMIT 10 """ results = DB.getAll(query) for i in range(len(results)): #Build a string of author_ids, e.g. '1314,4134,2624,2342' But, I'd like to fetch some info about each author_id from server 2: query = """SELECT id, avatar_url FROM members WHERE id IN (%s) """ values = (uid_list) results = DB.getAll(query, values) Now I need some way to combine these two queries so I have a dict that has the story as well as avatar_url and member_id. If this data were on one server, it would be a simple join that would look like: SELECT * FROM members, stories WHERE members.id = stories.author_id But since we store the data on multiple servers, this is not possible. What is the most efficient way to do this? Thanks.

    Read the article

  • C++ - Print Out Objects From Set

    - by John Smith
    If I have a C++ set, declaration set personList; with iterator, set::const_iterator location; how can I print out the contents of the set? They are all person objects, and I have overridden the operator<< for Person. The line that errors is: cout << location and it's in a basic for loop. Netbeans gives the following error: proj.cpp:78: error: no match for ‘operator<<’ in ‘std::cout << location’ so it looks like it wants an override for the iterator's <<. Basically, I am taking objects that used to be stored in an array format, but are now in a set. What is the equivalent to cout << array[i] for sets?

    Read the article

  • FaceBook like error

    - by user1150440
    I am using the following code in Page_Load Dim metaTagDesc As New HtmlMeta() 'Create a new instance of META tag object Dim metaTagKeywords As New HtmlMeta() Dim metaTagKeywords1 As New HtmlMeta() Dim metaTagKeywords2 As New HtmlMeta() metaTagDesc.Attributes.Add("property", "og:title") ' Add attributes to the META tag object for identification metaTagDesc.Attributes.Add("content", _table.Rows(0).Item(2)) metaTagKeywords.Attributes.Add("property", "og:type") metaTagKeywords.Attributes.Add("content", "website") metaTagKeywords1.Attributes.Add("property", "og:url") metaTagKeywords1.Attributes.Add("content", "http://citizen.tricedeals.com/Reports/" & _table.Rows(0).Item(0)) metaTagKeywords2.Attributes.Add("property", "og:image") metaTagKeywords2.Attributes.Add("content", "http://citizen.tricedeals.com/ProfilePictures/" & _table.Rows(0).Item(1) & ".jpg") Page.Header.Controls.Add(metaTagDesc) Page.Header.Controls.Add(metaTagKeywords) Page.Header.Controls.Add(metaTagKeywords1) Page.Header.Controls.Add(metaTagKeywords2) But i keep getting this error..."Your og:type object name has disallowed characters in it. It must match [a-z][a-z0-9._]*" Why?

    Read the article

  • Java Program Compiles and Runs, but doesn't work

    - by Richard Long
    When I run this program I enter information in a text box, push the search button, but nothing happens. The program just sits there until I press Cntrl C to break it. It looks like it should work, but I can't figure out what is hanging the program up. Here is the code: First class: import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class NameGameFrame extends JFrame { public static String name; static JTextField textfield = new JTextField(20); static JTextArea textarea = new JTextArea(30,30); public static String num; public static String [] fields; public static int [] yearRank; public static boolean match; public static int getInts, marker, year, max; public static void main( String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Name Game"); frame.setLocation(500,400); frame.setSize(800,800); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); JLabel label = new JLabel("Enter the Name or Partial Name to search:"); c.gridx = 0; c.gridy = 0; c.insets = new Insets(2,2,2,2); panel.add(label,c); c.gridx = 0; c.gridy = 1; panel.add(textarea,c); JButton button = new JButton("Search"); c.gridx = 1; c.gridy = 1; panel.add(button,c); c.gridx = 1; c.gridy = 0; panel.add(textfield,c); frame.getContentPane().add(panel, BorderLayout.NORTH); frame.pack(); frame.setVisible(true); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { name = textfield.getText(); java.io.File file = new java.io.File("namesdata.txt"); try { Scanner input = new Scanner(file); num = input.nextLine(); NameRecord nr = new NameRecord(name); while (input.hasNext()) { if(match = num.toLowerCase().contains(name.toLowerCase())) { nr.getRank(); nr.getBestYear(marker); } } } catch(FileNotFoundException e) { System.err.format("File does not exist\n"); } textarea.setText(fields[0]); } }); } } This is the second class: import java.io.*; import java.util.*; public class NameRecord { public NameRecord( String name) { } public static int getBestYear(int marker) { switch (marker) { case 1: year = 1900; break; case 2: year = 1910; break; case 3: year = 1920; break; case 4: year = 1930; break; case 5: year = 1940; break; case 6: year = 1950; break; case 7: year = 1960; break; case 8: year = 1970; break; case 9: year = 1980; break; case 10: year = 1990; break; case 11: year = 2000; break; } return year; } public static int getRank() { fields = num.split(" "); max = 0; for (int i = 1; i<12; i++) { getInts = Integer.parseInt(fields[i]); if(getInts>max) { max = getInts; marker = i; } } return max; } }

    Read the article

  • How do I write a spec for a Rails route that does redirecting?

    - by winstonyw
    I am using Omniauth in my Rails project, and I'll like to hide "/auth/facebook" behind a "/login" route. In fact, I wrote a route: match "/login", :to => redirect("/auth/facebook"), :as => :login and this actually works, i.e. a link to login_path will redirect to /auth/facebook. However, how can I write a (rspec) spec to test this route (specifically, the "redirect" option)? Do note that /login is not an actual action nor method defined in application. Thanks in advance!

    Read the article

  • Custom nib UITableViewCell height

    - by Chuck
    I've created a custom UITableViewCell in IB, linked it to the root view controller's property for it, and set it up in CellForRowAtIndexPath. But the height of my drawn cells doesn't match what I setup in IB, advice? Here's some screenshots and the code. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *AddressCellIdentifier = @"AddressCellIdent"; UITableViewCell *thisCell = [tableView dequeueReusableCellWithIdentifier:AddressCellIdentifier]; if (thisCell == nil) { [[NSBundle mainBundle] loadNibNamed:@"AddressCell" owner:self options:nil]; thisCell = addressCell; self.addressCell = nil; } return thisCell ; } addressCell is a @property (nonatomic, assign) IBOutlet UITableViewCell *addressCell;, and is linked up in IB to the file's owner (the table view controller). I'm using the example from Apple's table view programming guide.

    Read the article

  • Need to dynamically-generate a "sticky note" text

    - by gravyface
    Working on a website that has an image of a sticky note which will change text somewhat frequently (every month or so) as new "todo" items are created on it. Font I'm currently using is not Web Safe and the text is slightly angled to match the skew of the sticky note as well. Now I'm a pragmatist, and in situations like this I would normally secede defeat and opt for something more CSS/HTML practical. But no more! I'm falling a bit behind on what's going on with HTML5, CSS3, PNG graphics, Flash (ugh), and/or any other rich visuals. I'm decent with PHP/CSS/JS (jquery), have dabbled in Flash/actionscript too. My question is: what tools/method should I be looking at here?

    Read the article

  • How to get regex split from other var

    - by Dean
    Hi, $dbLink = mysql_connect('localhost', 'root', 't'); mysql_select_db('pc_spec', $dbLink); $html = file_get_contents('http://localhost/pc_spec/scrape.php?q=amd+955'); echo $html; $html = strip_tags($html); $price = ereg("\$.{6}", $html); $html = mysql_real_escape_string($html); $price = mysql_real_escape_string($price); $insert = mysql_query("INSERT INTO parts(part, price) values('$html','$price')") or var_dump(mysql_error()); How can I get $price to match $.{6} and insert this value (eg. $111.11) into a database and remove it from $html? Do I need to use explode? Thanks

    Read the article

  • SQL COUNT records in table 2 JOINS away

    - by Fred K
    Using MySQL, I have three tables: projects: ID name 1 "birthday party" 2 "soccer match" 3 "wine tasting evening" 4 "dig out garden" 5 "mountainbiking" 6 "making music" batches: ID projectID templateID when 1 1 1 7 days before 2 1 1 1 day before 3 4 2 21 days before 4 4 1 7 days before 5 5 1 7 days before 6 3 5 7 days before 7 3 3 14 days before 8 5 1 14 days before templates: ID message 1 "Hi, I'd like to invite ..." 2 "Dear Sir, Madam, ..." 3 "Can you please ..." 4 "Would you like to ..." 5 "To all dear friends ..." 6 "Does any of you guys ..." I would like to display a table of templates and the number of projects they're used in. So, the result should be: templateID projectCount 1 3 2 1 3 1 4 0 5 1 6 0 I've tried all kinds of SQL queries using various JOINs, but I guess this is too complicated for me. Is it possible to get this result using a single SQL statement?

    Read the article

  • Java Split not working as expected

    - by daaabears
    I am trying to use a simple split to break up the following string: 00-00000 My expression is: ^([0-9][0-9])(-)([0-9])([0-9])([0-9])([0-9])([0-9]) And my usage is: String s = "00-00000"; String pattern = "^([0-9][0-9])(-)([0-9])([0-9])([0-9])([0-9])([0-9])"; String[] parts = s.split(pattern); If I play around with the Pattern and Matcher classes I can see that my pattern does match and the matcher tells me my groupCount is 7 which is correct. But when I try and split them I have no luck.

    Read the article

  • How to code an efficient blacklist filter function in php?

    - by achairapart
    So, I have three arrays like this: [items] => Array ( [0] => Array ( [id] => someid [title] => sometitle [author] => someauthor ... ) ... ) and also a string with comma separated words to blacklist: $blacklist = "some,words,to,blacklist"; Now I need to match these words with (as they can be one of) id, title, author and show results accordingly. I was thinking of a function like this: $pattern = '('.strtr($blacklist, ",", "|").')'; // should return (some|words|etc) foreach ($items as $item) { if ( !preg_match($pattern,$item['id']) || !preg_match($pattern,$item['title']) || !preg_match($pattern,$item['author']) ) { // show item } } and I wonder if this is the most efficient way to filter the arrays or I should use something with strpos() or filter_var with FILTER_VALIDATE_REGEXP ... Note that this function is repeated per 3 arrays. However, each array will not contain more than 50 items.

    Read the article

  • PHP read a cookie that is on another domain

    - by pnm123
    Hello, I have two domains. One domain contains the login script. It creates a cookie when logged in. Another domain have a URL shortener. So, on the 2nd domain that have the URL Shortener script have a file called session.php. Usually I was using $_COOKIE['sessionid'] to get the session id and match it using database. How can I get the session id now? I have tried few ways but none of them have solve my problem. Thank you, pnm123

    Read the article

  • Using Drools to provide error processing and consequence management

    - by Mike
    Hi, I am working on a module whose purpose is to process Java exceptions and decide upon a strategy for dealing with them. The exceptions could be things I know about (explicit business exceptions eg TransformationException) or more general environmental stuff (JMS errors, IO errors etc) The facts inserted into the knowledge base are all the same class, and wrap (contain) an Exception. I want to write a rule that will explicitly match the exceptions I know how to deal with (eg TransformationException) and have another rule that catches 'everything else' The problem seems to me to be that for a fact containing a TransformationException, both rules will fire and the output will be uncertain. How would I go about writing such exclusive rules without relying on salience to steer the order of execution (this seems to be bad practice from what I have read)? I have a solution in place that I am not happy with whereby the outcome depends on the order in which the rules are defined in my .drl.

    Read the article

  • Probability Question

    - by Juddling
    if i pick 10 numbers from a possible 80. what is the probablity for someone else picking the same 10 numbers as me? or just 4 numbers? or no numbers? i think it's no matches: 10/80 one match: 10*9/80*79 so the formula would be (10!/matches!)/(80!/matches!) is this right? i've only just started doing this at A-level and i need it for a game script i'm making.

    Read the article

  • Document/Scripts management for R code

    - by harshsinghal
    Hi useRs, I am looking for a solution that allows me to keep a track of a multitude of R scripts that I create for various projects and purposes. Some scripts are easily tracked to specific projects, whereas others are "convenience" functions created to serve a set of tasks. Is there a way I can create a central DB and query it to find which scripts match most appropriately? I could create a system using a DBMS manually, but are users aware of anything in general or specific to R, that comes in the form of a software tool (maybe FOSS) ?

    Read the article

< Previous Page | 168 169 170 171 172 173 174 175 176 177 178 179  | Next Page >