Search Results

Search found 6569 results on 263 pages for 'specification pattern'.

Page 97/263 | < Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >

  • Java - Unknown characters passing as [a-zA-z0-9]*?

    - by Twodordan
    Hello, I'm no expert in regex but I need to parse some input I have no control over, and make sure I filter away any strings that don't have A-z and/or 0-9. When I run this, Pattern p = Pattern.compile("^[a-zA-Z0-9]*$"); //fixed typo if(!p.matcher(gottenData).matches()) System.out.println(someData); //someData contains gottenData certain spaces + an unknown symbol somehow slip through the filter (gottenData is the red rectangle): In case you're wondering, it DOES also display Text, it's not all like that. For now, I don't mind the [?] as long as it also contains some string along with it. Please help. [EDIT] as far as I can tell from the (very large) input, the [?]'s are either white spaces either nothing at all; maybe there's some sort of encoding issue, also perhaps something to do with #text nodes (input is xml)

    Read the article

  • Grouping string by comma between brackets

    - by Myra
    Response to : http://stackoverflow.com/questions/1454913/regular-expression-to-find-a-string-included-between-two-characters-while-exclud Hi,I'm looking for a regex pattern that applies to my string including brackets: [1,2,3,4,5] [abc,ef,g] [0,2,4b,y7] could be anything including word,digit,non-word together or separated. I wish to get the group between brackets by \[(.*?)\] but what is the regex pattern that will give me the group between brackets and sub-group strings separated by commas so that the result may be following ?? Group1 : [1,2,3,4,5] Group1: 1 Group2: 2 Group3: 3 Group4: 4 Group5: 5 Group2 : [abc,ef,g] Group1: abc Group2: ef Group3: g etc .. Thank you for your help

    Read the article

  • Regular expressions in python unicode

    - by Remy
    I need to remove all the html tags from a given webpage data. I tried this using regular expressions: import urllib2 import re page = urllib2.urlopen("http://www.frugalrules.com") from bs4 import BeautifulSoup, NavigableString, Comment soup = BeautifulSoup(page) link = soup.find('link', type='application/rss+xml') print link['href'] rss = urllib2.urlopen(link['href']).read() souprss = BeautifulSoup(rss) description_tag = souprss.find_all('description') content_tag = souprss.find_all('content:encoded') print re.sub('<[^>]*>', '', content_tag) But the syntax of the re.sub is: re.sub(pattern, repl, string, count=0) So, I modified the code as (instead of the print statement above): for row in content_tag: print re.sub(ur"<[^>]*>",'',row,re.UNICODE But it gives the following error: Traceback (most recent call last): File "C:\beautifulsoup4-4.3.2\collocation.py", line 20, in <module> print re.sub(ur"<[^>]*>",'',row,re.UNICODE) File "C:\Python27\lib\re.py", line 151, in sub return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or buffer What am I doing wrong?

    Read the article

  • Is there something similar to 'rake routes' in django?

    - by The MYYN
    In rails, on can show the active routes with rake (http://guides.rubyonrails.org/routing.html): $ rake routes users GET /users {:controller=>"users", :action=>"index"} formatted_users GET /users.:format {:controller=>"users", :action=>"index"} POST /users {:controller=>"users", :action=>"create"} POST /users.:format {:controller=>"users", :action=>"create"} Is there a similar tool/command for django showing the e.g. the URL pattern, the name of the pattern (if any) and the associated function in the views?

    Read the article

  • Optimizing simple search script in PowerShell

    - by cc0
    I need to create a script to search through just below a million files of text, code, etc. to find matches and then output all hits on a particular string pattern to a CSV file. So far I made this; $location = 'C:\Work*' $arr = "foo", "bar" #Where "foo" and "bar" are string patterns I want to search for (separately) for($i=0;$i -lt $arr.length; $i++) { Get-ChildItem $location -recurse | select-string -pattern $($arr[$i]) | select-object Path | Export-Csv "C:\Work\Results\$($arr[$i]).txt" } This returns to me a CSV file named "foo.txt" with a list of all files with the word "foo" in it, and a file named "bar.txt" with a list of all files containing the word "bar". Is there any way anyone can think of to optimize this script to make it work faster? Or ideas on how to make an entirely different, but equivalent script that just works faster? All input appreciated!

    Read the article

  • How can i pass a single additional argument to array_map callback in PHP?

    - by Gremo
    How can i pass a single additional argument to array_map callback? In my example i'd like to pass $smsPattern (as a second argument, after current element in $featureNames) to the function array_map with $getLimit closure: $features = $usage->getSubscription()->getUser()->getRoles(); // SMS regular expression in the form of ROLE_SEND_SMS_X $smsPattern = '/^ROLE_SEND_SMS_(?P<l>\d+)$/i'; // Function to get roles names and X from a role name $getNames = function($r) { return trim($r->getRole()); }; $getLimit = function($name, $pattern) { if(preg_match($pattern, $name, $m)) return $m['l']; }; // Get roles names and their limits ignoring null values with array_filter $featuresNames = array_map($getNames, $features); $smsLimits = array_filter(array_map($getLimit, $featureNames, $smsPattern)); With this code i'm getting a weird warning: Warning: array_map() [function.array-map]: Argument #3 should be an array. Of course di reason is for reusing $getLimit closure with another regular expression like $smsPattern. Thanks.

    Read the article

  • preg_match not defined in php4 in openwrt?

    - by user2723949
    I have installed the packages PHP4 and PHP4-CGI in openwrt through command line (opkg install) when I tried this simple code by putting this in the openwrt www folder, <?php $subject = "abcdef"; $pattern = '/^def/'; preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3); print_r($matches); ?> I got this error Fatal error: Call to undefined function: preg_match() in /www/phptest.php on line 4 but php manual says preg_match() is defined in php4 also.. What might be the reason for this error? Is there any other PHP module that is to be installed? Or is there any alternate method for preg_match?

    Read the article

  • Why isn't my File.Move() working?

    - by yeahumok
    I'm not sure what exactly i'm doing wrong here...but i noticed that my File.Move() isn't renaming any files. Also, does anybody know how in my 2nd loop, i'd be able to populate my .txt file with a list of the path AND sanitized file name? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Text.RegularExpressions; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { //recurse through files. Let user press 'ok' to move onto next step string[] files = Directory.GetFiles(@"C:\Documents and Settings\jane.doe\Desktop\~Test Folder for [SharePoint] %testing", "*.*", SearchOption.AllDirectories); foreach (string file in files) { Console.Write(file + "\r\n"); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); //End section //Regex -- find invalid chars string pattern = " *[\\~#%&*{}/<>?|\"-]+ *"; string replacement = " "; Regex regEx = new Regex(pattern); string[] fileDrive = Directory.GetFiles(@"C:\Documents and Settings\jane.doe\Desktop\~Test Folder for [SharePoint] %testing", "*.*", SearchOption.AllDirectories); List<string> filePath = new List<string>(); //clean out file -- remove the path name so file name only shows string result; foreach(string fileNames in fileDrive) { result = Path.GetFileName(fileNames); filePath.Add(result); } StreamWriter sw = new StreamWriter(@"C:\Documents and Settings\jane.doe\Desktop\~Test Folder for [SharePoint] %testing\File_Renames.txt"); //Sanitize and remove invalid chars foreach(string Files2 in filePath) { try { string sanitized = regEx.Replace(Files2, replacement); sw.Write(sanitized + "\r\n"); System.IO.File.Move(Files2, sanitized); System.IO.File.Delete(Files2); } catch (Exception ex) { Console.Write(ex); } } sw.Close(); } } } I'm VERY new to C# and trying to write an app that recurses through a specific drive, finds invalid characters (as specified in the RegEx pattern), removes them from the filename and then write a .txt file that has the path name and the corrected filename. Any ideas?

    Read the article

  • How do I implement a DataGrid with an MVVM approach.

    - by Fred
    Hi, I'd like to implement a sort of Addressbook/Contactbook using a Datagrid (or a List) and the MVVM pattern. Something like in Outlook/Thunderbird, where you've a list of your contacts displayed with a 2-3 main fields (name surname for example), and when you double-click a contact, then you get a new modal box that displays all the details of this specific contact. Since a couple of weeks/months, I'm reading a lot of stuff about MVVM pattern on the net, but somehow, I get confused. Until now, I could find any sample like this. (perhaps, I searched wrong?) How could I organize such an application? Thx in advance for your help.

    Read the article

  • Lazy loading? Better avoiding it?

    - by Charlie Pigarelli
    I just read about this design pattern: Lazy Load. And, since in the application i'm working on i have all the classes in one folder, i was wondering if this pattern could just make me avoiding the include() function for every class. I mean: It's nice to know that if i forgot to include a class, PHP, before falling into an error, trough an __autoload() function try to get it. But is it fine enough to just don't care about including classes and let PHP do it by your own every time? Or we should write __autoload() just in case it is needed?

    Read the article

  • Loop and ListView

    - by monomi
    I find a match with Regexp. How to correctly organize a loop, if more than one match and write it in the ListView? listAlbums = (ListView)findViewById(R.id.listAlbums); ... Pattern patternNameToId = Pattern.compile(kRegexp); String nameTo = "" Matcher matcherName = patternNameToId.matcher(response); if (matcherName.find()) { nameTo = matcherTopicTitle.group(2); albumsList = new ArrayList<String>(); albumsList.add(nameTo); ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, albumsList); listAlbums.setAdapter(adapter); } else Toast.makeText(context, "?? ???????", Toast.LENGTH_LONG).show();

    Read the article

  • Jenkins Build fails when artifacts are not there

    - by leifg
    I use Jenkins to run some integration tests on a web appilcation (using cucumber, capybara and selenium) Everytime a test fails, a screenshot, the HTML source and a video of the process is saved. the path structure looks like this: results/output/<test_name>/<files> I use the archive artifacts feature of Jenkins to provide the files (pattern: results/output/*/*). It works great. However as soon as a build succeeds, there are no screenshots/videos etc... and the build fails because Jenkins cannot find the files for the pattern. Is there a way to tell Jenkins to succeed without having the files present? I don't want to do a dirty hack which involves creating an empty folder structure like result/output/success/hooray.txt.

    Read the article

  • J2EE/EJB + service locator: is it safe to cache EJB Home lookup result ?

    - by Guillaume
    In a J2EE application, we are using EJB2 in weblogic. To avoid losing time building the initial context and looking up EJB Home interface, I'm considering the Service Locator Pattern. But after a few search on the web I found that event if this pattern is often recommended for the InitialContext caching, there are some negative opinion about the EJB Home caching. Questions: Is it safe to cache EJB Home lookup result ? What will happen if one my cluster node is no more working ? What will happen if I install a new version of the EJB without refreshing the service locator's cache ?

    Read the article

  • PHP regular expression subpattern behaviour

    - by codecowboy
    I want to match both the src and title attributes of an image tag: pattern: <img [^>]*src=["|\']([^"|\']+["|\'])|title=["|\']([^"|\']+) target: <img src="http://someurl.jpg" class="quiz_caption" title="Caption goes here!"> This pattern gives me one unwanted match, title="content", and the match I actually want which is the value between the quotes after the word 'title', i.e 'content'. So, my matches are: <img src="http://someurl.jpg http://someurl.jpg title="Caption goes here!" Caption goes here! Is there a way to avoid the third of these matches? I'm using PCRE in PHP 5.2.x

    Read the article

  • javascript validate zip regular expression

    - by phil
    It's not working. Probably it's syntax error, but I can't figure it out. <script src="jquery-1.4.2.min.js" type="text/javascript"></script> <script> pattern=/^[0-9]{5}$/; if (!pattern.test($('#zip').val)) {$('#zip').append($('<p>',{html: zip is invalid}));} </script> zip (US only): <input type="text" name='zip' id='zip' maxlength="5">

    Read the article

  • Getting 403 error when using CSRF filter with tomcat 6.0.32

    - by sps
    This is my filer config in web.xml <filter> <filter-name>CSRFPreventionFilter</filter-name> <filter-class>org.apache.catalina.filters.CsrfPreventionFilter</filter-class> <init-param> <param-name>entryPoints</param-name> <param-value>/login<param-value> </init-param> </filter> <filter-mapping> <filter-name>CSRFPreventionFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> Am I missing something? Are any code-changes necessary to enable csrf protection in tomcat

    Read the article

  • Stored Connection Strings per user

    - by pehaada
    In the past I've used a Singleton Pattern to load the connection string when the application starts via the global.asa file. I have a project now where each user has a unique connection string to the database. I would like to load this connection string once. The issue is that the singleton pattern will not work for me since each user has there own connection string. Basically the connection string is created dynamically. I do not want to store it is session. If anyway has a clever way of doing this in .NET let me know ?

    Read the article

  • Singletons vs. Application Context in Android?

    - by mschonaker
    Recalling this post enumerating several problems of using singletons and having seen several examples of Android applications using singleton pattern, I wonder if it's a good idea to use Singletons instead of single instances shared through global application state (subclassing android.os.Application and obtaining it through context.getApplication()). What advantages/drawbacks would have both mechanisms? To be honest, I expect the same answer in this post http://stackoverflow.com/questions/2709071/singleton-pattern-with-web-application-not-a-good-idea but applied to Android. Am I correct? What's different in DalvikVM otherwise? EDIT: I would like to have opinions on several aspects involved: Synchronization Reusability Testing Thanks in advance.

    Read the article

  • character matching in grayscale image

    - by maximus
    I made patterns: images with the "A" letter of different sizes (from 12 to 72: 12, 14, .., 72) And I tested the method of pattern matching and it gave a good results. One way to select text regions from image is to run that algorithm for all small and big letters and digits of different sizes. And fonts! I don't like it. Instead of it I want to make something like a universal pattern or better to say: scanning image with different window sizes and select those regions where some function (probability of that there is a character at that window) is more than some fixed value. Do you know any methods or ideas to make that function? It must work with original image (grayscale).

    Read the article

  • How to create a valid schema in a WSDL that restrict to <|<=|>|>=

    - by wsxedc
    This is what I have in my schema section of my WSDL to specify the field has to be comparison operators <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="&lt;|&gt;|&lt;=|&gt;=|="/> </xsd:restriction> </xsd:simpleType> SoapUI complains about this part of the WSDL, I tried to set the value to something with non special characters and the WSDL is valid. So I tried to replace that whole long string to be value=">gt;" and it valid but value="<lt;" is not valid, and value=">" is also not valid. My question is, why does the WSDL validation need > to be double escaped? The main question is, how to provide a valid less than side within the pattern value.

    Read the article

  • Is this a valid, lazy, thread-safe Singleton implementation for C#?

    - by Matthew
    I implemented a Singleton pattern like this: public sealed class MyClass { ... public static MyClass Instance { get { return SingletonHolder.instance; } } ... static class SingletonHolder { public static MyClass instance = new MyClass (); } } From Googling around for C# Singleton implementations, it doesn't seem like this is a common way to do things in C#. I found one similar implementation, but the SingletonHolder class wasn't static, and included an explicit (empty) static constructor. Is this a valid, lazy, thread-safe way to implement the Singleton pattern? Or is there something I'm missing?

    Read the article

  • Is there a browser independet bookmarktool supporting tags, date and free comments?

    - by bernd_k
    I am looking for a tool, which helps me to organize my personal bookmarks. I want to be able to assign tags and free comments to a bookmark. I want to search my bookmarks by tags date of bookmarking pattern in title pattern in url It would be nice to be web based to enable sharing my bookmarks between different machines. But for it would be OK, if it works on a single machine as long as it has some import/export way to transfer the links to a new machine replacing the old. As browsers I'm using Firefox and ChromePlus. It would be nice, if the solution works with both browsers. With free comments, I mean additional remarks stored for a bookmark, which is not essential for searching.

    Read the article

< Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >