Search Results

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

Page 19/263 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Finding a pattern within a string variable in C#

    - by lo3
    Ok i'm working on a project for a 200 level C# course, we are required to create a heads or tails project. Basically the project is setup so that the computer will guess randomly up to 5 times, but on the sixth time it will look into the playersGuessHistory variable setup as a string to see if it can find a match for a pattern of 4 entires, if there is a pattern found the computer will guess the next character after the pattern EX: [HHTT]H [HHTTH]H HHTT being the pattern then the computer would guess H for the next turn. My only problem is that i'm having difficulty setting up the project so that it will look through the playersguesshistory and find the patterns and guess the next character in the history. Any suggestions?

    Read the article

  • php replace a pattern

    - by Hulk
    Suppose in a file there is a pattern as sumthing.c: and asdfg.c: and many more.. with *.c: pattern How to replace this with the text yourinput and save the file using php The pattern is *.c thanks..

    Read the article

  • Best practice for DAO pattern ?

    - by Tony
    I've seen a lot of codes use a service-dao pattern , I don't know the origin of this pattern . It force the front layer call service , then delegates some of the service task to dao. I want to ask : Does DAO layer do purely data access related task ? What about exception encapsulation ? Is there other pattern can be used to replace this ?

    Read the article

  • PRG Pattern and Sticky Forms

    - by Scott Christopherson
    I'm using the PRG pattern on a form of mine. I've never used this approach before and I'm trying to figure something out: Normally, I always just displayed the posted form again when there were validation errors and displayed POST values in the form (sticky form). However with the PRG pattern, the form is displayed after a redirect, so there aren't any POST values. So my question is, how can I implement the PRG pattern and still have sticky forms?

    Read the article

  • Ignore duplicates in regex pattern

    - by gAMBOOKa
    I have a regex pattern that searches for words in a text file. How do I ignore duplicates? For instance, take a look at this code $pattern = '/(lorem|ipsum|daboom|pahwal|ababaga)/i'; $num_found = preg_match_all( $pattern, $string, $matches ); echo "$num_found match(es) found!"; echo "Matched words: " . implode( ',', $matches[0] ); If I have more than one say lorem in the article, the output will be something like this 5 matches found! Matched words: daboom,lorem,lorem,lorem,lorem I want the pattern to only find the first occurrence, and ignore the rest, so the output should be: 2 matches found! Matched words: daboom,lorem

    Read the article

  • What design pattern do you use the most?

    - by spoon16
    I'm interested in understanding what design patterns people find themselves using often. Hopefully this list will help other recognize common scenarios and the associated design pattern that can be used to solve them. Please describe a common problem you find yourself solving and the design pattern(s) you use to solve it. Links to blogs or documentation describing the pattern are also appreciated. Edit: Please expand on your answers a bit, I would like this to be a useful reference for someone who wants to learn more about design patterns and is curious on what situations a specific design pattern might be used. Nobody has linked to any "more learning" resources.

    Read the article

  • Post/Redirect/Get Pattern and Sticky Forms

    - by Scott Christopherson
    I'm using the Post/Redirect/Get pattern on a form of mine. I've never used this approach before and I'm trying to figure something out: Normally, I always just displayed the posted form again when there were validation errors and displayed POST values in the form (sticky form). However with the PRG pattern, the form is displayed after a redirect, so there aren't any POST values. So my question is, how can I implement the PRG pattern and still have sticky forms?

    Read the article

  • Android pattern locking

    - by JonF
    I have been able to lock the screen using LOCK_PATTERN_ENABLED, however in many cases when I enable this pattern locking it will take any pattern and move past the pattern check. Has anyone else run across this?

    Read the article

  • Regular Expression to replace a pattern at runtime(C#3.0)

    - by deepak.kumar.goyal
    I have a requirement. I have some files in a folder among which some file names looks like say **EUDataFiles20100503.txt, MigrateFiles20101006.txt.** Basically these are the files that I need to work upon. Now I have a config file where it is mentioned as the file pattern type as EUDataFilesYYYYMMDD, MigrateFilesYYYYMMDD. Basically the idea is that, the user can configure the file pattern and based on the pattern mentioned, I need to search for those files that are present in the folder. i.e. at runtime the YYYYMMDD will get replaced by the Year Month and Date Values. It does not matter what dates will be there(but not with time stamp ; only dates)). And the EUDataFiles or MigrateFiles names will be there.(they are fixed) i.e. If the folder has a file name as EUDataFile20100504.txt(i.e. Year 2010, Month 05, Day 04) , I should ignore this file as it is not EUDataFiles20100504.txt (kindly note that the name is plural - File(s) and not file for which the system will ignore the file). Similarly, if the Pattern given as EUDataFilesYYYYMMDD and if the file present is of type EUDataFilesYYYYDDMM then also the system should ignore. How can I solve this problem? Is it doable using regular expression(Replacing the pattern at runtime)? If so can anyone be good enough in helping me out? I am using C#3.0 and dotnet framework 3.5. Thanks

    Read the article

  • Delete all characters in a multline string upto a given pattern

    - by biffabacon
    Using Python I need to delete all charaters in a multiline string up to the first occurrence of a given pattern. In Perl this can be done using regular expressions with something like: #remove all chars up to first occurrence of cat or dog or rat $pattern = 'cat|dog|rat' $pagetext =~ s/(.*)($pattern)/$2/xms; What's the best way to do it in Python?

    Read the article

  • Bash Script using Grep to search for a pattern in a file

    - by atif089
    I am writing a bash script to search for a pattern in a file using GREP. I am clueless for why it isnt working. This is the program echo "Enter file name..."; read fname; echo "Enter the search pattern"; read pattern if [ -f $fname ]; then result=`grep -i '$pattern' $fname` echo $result; fi Or is there different approach to do this ? Thanks

    Read the article

  • Exploring the Factory Design Pattern

    - by asksuperuser
    There was an article here: http://msdn.microsoft.com/en-us/library/Ee817667%28pandp.10%29.aspx The first part of tut implemented this pattern with abstract classes. The second part shows an example with Interface class. But nothing in this article discusses why this pattern would rather use abstract or interface. So what explanation (advantages of one over the other) would you give ? Not in general but for this precise pattern.

    Read the article

  • Delete all characters in a multline string up to a given pattern

    - by biffabacon
    Using Python I need to delete all charaters in a multiline string up to the first occurrence of a given pattern. In Perl this can be done using regular expressions with something like: #remove all chars up to first occurrence of cat or dog or rat $pattern = 'cat|dog|rat' $pagetext =~ s/(.*?)($pattern)/$2/xms; What's the best way to do it in Python?

    Read the article

  • Decorator Pattern - Multiple wrappers or quantity property?

    - by Jiminizer
    I'm making use of the decorator pattern for one of the first times, as part of a Uni project. As far as I can see, the pattern seems to be meant more for adding functionality in a modular manner, however we've been taught it with uses such as a coffee or pizza maker, where the object has modular components that are added - changing properties rather than behaviour. I'm trying to make the most of both uses, however I've come up with a question. In the example in the book we're using (Head First Design Patterns), the pattern is used in a coffee shop creating different coffees. So, for example, milk, froth, sugar, sprinkles are all decorators. How would you implement a system that used the same decorator multiple times (for example, a coffee with two sugars)? Would you rewrap the coffee, or give sugar a quantity property? Or (as i'm starting to suspect) would this never be an issue as the pattern isn't designed to be used this way?

    Read the article

  • String pattern matching in Javascript

    - by kwokwai
    Hi all, I am doing some self learning about Patern Matching in Javascript. I got a simple input text field in a HTML web page, and I have done some Javascript to capture the string and check if there are any strange characters other than numbers and characters in the string. But I am not sure if it is correct. Only numbers, characters or a mixture of numbers and characters are allowed. var pattern = /^[a-z]+|[A-Z]+|[0-9]+$/; And I have another question about Pattern Matching in Javascript, what does the percentage symbol mean in Pattern matching. For example: var pattern = '/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/';

    Read the article

  • Is this the Crudy anti pattern?

    - by miker169
    Currently I am creating a WCF service which has to connect to a DAL which, just connects to a database using ADO.net and stored procedures. The DAl writes its responses from the database to a datacontract which is passed over the wire to the client via the service. I was reading that this may possibly be the anti pattern 'CRudy Interface', but I wasn't sure as I am sharing the datacontract. If I am using an anti pattern, can anyone suggest a better pattern to use for the behavior I require? Thanks

    Read the article

  • Cygwin diff won't exclude files if a directory is included in the pattern

    - by Dean Schulze
    I need to do a recursive diff using cygwin that needs do exclude all .xml files from certain directories, but not from other directories. According to the --help option I should be able to do this with with the --exclude=PAT option where PAT is a pattern describing the files I want to exclude from the diff. If I do this: diff -rw --exclude="classes/Services.xml" the diff does not ignore the Services.xml file in the classes directory. If I do this diff -rw --exclude="Services.xml" the diff does ignore the Services.xml file in all directories. I need to do something like this: diff -rw --exclude="*/generated/resources/client/*.xml" to ignore all .xml files in the directory */generated/resources/client/. Whenever I add path information to the --exclude pattern cygwin does not ignore the file(s) I've specified in the pattern. Is there some way to make cygwin diff recognize a pattern that identifies certain files in certain directories? It seems to not be able to handle any directory information at all.

    Read the article

  • PHP : Pattern Replacement Query.

    - by Rachel
    Currently I have ‘customer_id’ . ‘+’ . ‘operator_domain’ pattern, e.g., '123456789'.'+'.'987654321' Desired Pattern: ‘customer_id.operator_domain’ pattern, e.g., '123456789987654321' How can I achieve this using in php ?

    Read the article

  • efficientcy effort: grep with a vectored pattern or match with a list of values

    - by Elad663
    I guess this is trivial, I apologize, I couldn't find how to do it. I am trying to abstain from a loop, so I am trying to vectorize the process: I need to do something like grep, but where the pattern is a vector. Another option is a match, where the value is not only the first location. For example data (which is not how the real data is, otherswise I would exploit it structure): COUNTRIES=c("Austria","Belgium","Denmark","France","Germany", "Ireland","Italy","Luxembourg","Netherlands", "Portugal","Sweden","Spain","Finland","United Kingdom") COUNTRIES_Target=rep(COUNTRIES,times=4066) COUNTRIES_Origin=rep(COUNTRIES,each=4066) Now, currently I got a loop that: var_pointer=list() for (i in 1:length(COUNTRIES_Origin)) { var_pointer[[i]]=which(COUNTRIES_Origin[i]==COUNTRS_Target) } The problem with match is that match(x=COUNTRIES_Origin,table=COUNTRIES_Target) returns a vector of the same length as COUNTRIES_Origin and the value is the first match, while I need all of them. The issue with grep is that grep(pattern=COUNTRIES_Origin,x=COUNTRIES_Target) is the given warning: Warning message: In grep(pattern = COUNTRIES_Origin, x = COUNTRIES_Target) : argument 'pattern' has length > 1 and only the first element will be used Any suggestions?

    Read the article

  • The Purpose of a Service Layer and ASP.NET MVC 2

    - by user332022
    In an effort to understand MVC 2 and attempt to get my company to adopt it as a viable platform for future development, I have been doing a lot of reading lately. Having worked with ASP.NET pretty exclusively for the past few years, I had some catching up to do. Currently, I understand the repository pattern, models, controllers, data annotations, etc. But there is one thing that is keeping me from completely understanding enough to start work on a reference application. The first is the Service Layer Pattern. I have read many blog posts and questions here on Stack Overflow, but I still don't completely understand the purpose of this pattern. I watched the entire video series at MVCCentral on the Golf Tracker Application and also looked at the demo code he posted and it looks to me like the service layer is just another wrapper around the repository pattern that doesn't perform any work at all. I also read this post: http://www.asp.net/Learn/mvc/tutorial-38-cs.aspx and it seemed to somewhat answer my question, however, if you are using data annotations to perform your validation, this seems unnecessary. I have looked for demonstrations, posts, etc. but I can't seem to find anything that simply explains the pattern and gives me compelling evidence to use it. Can someone please provide me with a 2nd grade (ok, maybe 5th grade) reason to use this pattern, what I would lose if I don't, and what I gain if I do?a

    Read the article

  • Junos custom-attack signature pattern syntax

    - by James Hawkwind
    I am stuck at a point with the configuration of a custom-attack signature in Junos. According to the Junos Custom Attack Definition documentation page, I can set up a custom attack based upon a signature in the packet. In the documentation you can specify a "pattern" to match, but it fails to describe what the pattern syntax should be. Particularly, I want to match the HEX values of 8C 00 13 00 in the first four bytes of the TCP data payload. Does anyone know how to accomplish this correctly?

    Read the article

  • grep pattern interpretted differently in 2 different systems with same grep version

    - by Lance Woodson
    We manufacture a linux appliance for data centers, and all are running fedora installed from the same kickstart process. There are different hardware versions, some with IDE hard drives and some SCSI, so the filesystems may be at /dev/sdaN or /dev/hdaN. We have a web interface into these appliances that show disk usage, which is generated using "df | grep /dev/*da". This generally works for both hardware versions, giving an output like follows: /dev/sda2 5952284 3507816 2137228 63% / /dev/sda5 67670876 9128796 55049152 15% /data /dev/sda1 101086 11976 83891 13% /boot However, for one machine, we get the following result from that command: Binary file /dev/sda matches It seems that its grepping files matching /dev/*da for an unknown pattern for some reason, only on this box that is seemingly identical in grep version, packages, kernel, and hardware. I switched the grep pattern to be "/dev/.da" and everything works as expected on this troublesome box, but I hate not knowing why this is happening. Anyone have any ideas? Or perhaps some other tests to try?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >