Regex Pattern For this String ":=)"

Hello All
True, this isn't the place to ask this but here it is anyway, if you can help please do.
Can anybody tell me the regex pattern for this String:
":=)"
Thanks
John

Yep, cheers it's ":=\\)"
public class Test {
     public static void main( String args[] ) {
          String s = "one:=)two:=)three:=)four";
          String ss[] = s.split( ":=\\)" );
          for( int i=0; i<ss.length; i++ )
               System.out.println( "ss["+i+"] = {" + ss[i] + "}" );
}resulting in:
ss[0] = {one}
ss[1] = {two}
ss[2] = {three}
ss[3] = {four}

Similar Messages

  • Is there a design pattern for this?

    I'm looking for a solution to a design problem I have.
    For a restaurant booking system I need a number of different opening times describing when you can and cannot book. These opening times are essentially Jodatime Period objects. There's a set of opening times spanning a week and these are repeated for every week (a default set of opening times) however it's possible to override these opening times say for a specific day.
    The domain model would be something like a Restaurant class holding 2 Lists of OpeningTime objects one for defaultOpeningTimes and the other for overiddenOpeningTimes the overidden ones get used if they exist for the requested time period. However the database model would be a bit messy as I'd have 2 lists mapping to the same table (OpeningTime). Is that a good idea? Perhaps there's a design pattern for this, if someone could point me in the right direction I'd be very grateful, or perhaps this is the best solution? Thanks!

    jduprez wrote:
    But why do you put the logic in the database too (I'm no DB expert and I didn't know these concepts until I read your post, but that's what a dynamic view based on derived values looks like to me): performance (1 round-trip instead of two)?Hi jduprez. Long time no speakee.
    I guess part of it is that I spent many years as a DBA and modeller, and really appreciate what it's taught me about design. Also, databases are (or should be) designed from the ground up to provide data-directed requests optimally, and include all sorts of nice stuff like transaction handling that aid consistency, as well as speed.
    That said: I HATE SQL. Think Coliseum, with that emblazoned in 60-foot high letters around its walls, and it might come close to just how much I hate that so-called "language". I hate its form; I hate it's inconsistencies; I hate the fact that something like what OP is trying to do is NOT an easy task (and might involve the creation of a table that simply contains Dates, just in order to satisfy Boolean logic).
    However, once you work it out, a database view (at least from the database's standpoint; JDBC I'm not so sure about) is just like any other Table - and that I DO like.
    Programs are good at processing parameterized (ugh) temporal information; databases are good at persistence and high volume. Those two may meet at some point, but I reckon it's going to take another Codd (or Joda) before it does.
    - that's clearer to 90% of the dev team (my biased numbers, based on 50% of Java developers having decent knowledge of SQL and much less than that having the advanced SQL knowledge which I rank your suggestion at)Sounds to me like you'll get the solution that matches the skills you have then. Is that what you really want, if a better one is available?
    - that doesn't require investigating the if of your suggestion (JDBC support)Agreed, but only because my JDBC knowledge isn't what it could be. I'd also be surprised if it doesn't support access to a named view, since they were designed to be equivalent to Tables.
    - the Op is using DAOs, so it's possible, if profiling does show this is hampering performances, to change that with no impact on the client code that calls the DAO.There's no doubt that a database solution is much higher level than a programming one; but, as I said, it's what they were designed to do. And tinkering around with program optimization has the feel of a "hacker's solution" to me. Not that there's any particular problem with that - I do it quite often when I have no control over my source - but I also try to keep in mind what the "actual" problem is.
    Winston

  • What is the best design pattern for this problem?

    No code to go with the question. I am trying to settle on the best design pattern for the problem before I code. I want to use an Object Oriented approach.
    I have included a basic UML diagram of what I was thinking so far. 
    Stated simply, I have three devices; Module, Wired Modem, and Wireless Modem.
    In the Device Under Test parent class, I have put the attributes that are variable from device to device, but common to all of them.
    In the child classes, I have put the attributes that are not variable to each copy of that device. The attributes are common across device types. I was planning to use controls in the class definition that have the data set to a default value, since it doesn't change for each serial number of that device. For example, a Module will always have a Device Type ID of 1. These values are used to query the database.
    An example query would be [DHR].[GetDeviceActiveVersions] '39288', 1, '4/26/2012 12:18:52 PM'
    The '1' is the device type ID, the 39288 is the serial number, and the return would be "A000" or "S002", for example.
    So, I would be pulling the Serial Number and Device Type ID from the Device Under Test parent and child, and passing them to the Database using a SQL string stored in the control of the Active Versions child class of Database.
    The overall idea is that the same data is used to send multiple queries to the database and receiving back various data that I then evaluate for pass of fail, and for date order.
    What I can't settle on is the approach. Should it be a Strategy pattern, A Chain of Command pattern, a Decorator pattern or something else. 
    Ideas?

    elrathia wrote:
    Hi Ben,
    I haven't much idea of how override works and when you would use it and why. I'm the newest of the new here. 
    Good. At least you will not be smaking with a OPPer dOOPer hammer if I make some gramatical mistake.
    You may want to look at this thread in the BreakPoint where i trie to help Cory get a handle on Dynamic Dispatching with an example of two classes that inherit from a common parent and invoke Over-ride VIs to do the same thing but with wildly varying results.
    The example uses a Class of "Numeric"  and a sibling class "Text" and the both implement an Add method.
    It is dirt simple and Cory did a decent job of explaining it.
    It just be the motivation you are looking for.
    have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Regex - Pattern for positive numbers

    Hi,
    I wanna check for positive numbers.
    My code so far:
    Pattern p = Pattern.compile("\\d+");
    Matcher m = p.matcher(str);
    boolean b = m.matches(); But I don't know how to check for positive numbers (including 0).
    Thanks
    Jonny

    Just to make your life easier:
    package samples;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    * @author notivago
    public class Positive {
        public static void main(String[] args) {
            String input = "- 12 +10 10 -12 15 -12,000 10,000 5,000.42";
            Pattern p = Pattern.compile( "\\b(?<!-\\s?|\\.|,)([0-9]+(?:,?[0-9]{3})*(?:\\.[0-9]*)?)" );
            Matcher matcher = p.matcher( input );
            while( matcher.find() ) {
                System.out.println( "Match: " + matcher.group(1) );
    }

  • Match pattern for multiple strings in labVIEW

    I want to include multiple strings for matching in the regular expression for pattern matching.I tried using the or option and (|)
    eg:cat|dog|mouse
    If the string contains any of these it should show a match.
    Is it possible in labview or do i need to use multiple patch mattern functions to achieve this?

    Match Regular Expression function will do.
    You can search for multiple strings using | operator. This function will return the match of any one of the specified strings seperated by | operator

  • How to use 'about' Contain operator for this string?

    Hi all,
    I need to search the following string in text index using about operator.
    'Advertisment for Product(Cosmetic)'
    How can I do this? If I use the following sql,
    SELECT keyword_id
    FROM keyword_text
    WHERE contains(fts_text_uc, convert('about(Advertisment for Product(Cosmetic))',
    'WE8MSWIN1252', 'WE8MSWIN1252')) > 0
    ORDER BY nlssort(text, 'NLS_SORT=EEC_EUROPA3')
    It gives following error.
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    Any body know how to write query for this?
    Thanx in advance
    T.Umapathy

    You'll need to quote the parantheses by putting backslashes in front of them:
    select text from t where contains (text, convert('about(Advertisement for Product\(Cosmetic\))', 'WE8MSWIN1252', 'WE8MSWIN1252')) > 0

  • Do I use the Brdige pattern for this problem ?

    Hello
    I'm making a music mixer for mobile phones. For the canvas, i divided it up in tiles, to fill
    up with .png images if you want to place a sample in that specific tile. But if you have a phone with no colors and your screen is not big enough, the image is almost all black. So I want to create a different class, to only show a letter or a simple symbol if you can't handle the .png well.
    I read about the bridge pattern, where you encapsulate the implementation in an abstract class and seperate it from the base class with the abstractions. Should I use this pattern for my problem ? I have some doubt because I have multiple implementations (color vs non-color) but I don't have multiple abstractions (a tile to fill up with a symbol or picture).
    Are there other patterns that are more suited for my problem ?
    What about the implementation? Should I see the implementation as only producing the image or symbol, or should i see it as the whole canvas, with the tile system?
    For example, now the tiling looks good on most of the targeted phones. But what if the next generation of mobile phones has a screen with very different dimensions. Wouldn't it be better to incorporate this also in the implementation ?
    Thanks

    What are you trying to do when you say "When I put the password for my apple ID into icloud- it keeps reverting to another password"?
    Where are you doing when you try to enter your password?

  • What's the regex pattern for regular English chars and numbers ...

    In Java String there is a matches(String regex) method, how can I specify the regex for regular English chars, I want it to tell me if the string contains non-English chars. The string is from an email, my application wants to know if the email contains any foreign characters, such as French, Spanish, Chinese ...
    So if the string looks like this : "Hi Frank, today is (5-7-2007), my address is : '[email protected]', email me ~ ! ^_^, do you know 1+2=3 ? AT&T, 200%, *[$300] | {#123}, / _ \;"
    It should recognize it as regular English characters.
    But if it contains any foreign language (outside of a-z) chars either western(Russian, Greek ...) or eastern languages (Japanese, Chinese ...), it should return false.
    I wonder how to write this "regex" ?
    Frank

    since french, english, and spanish use thesame
    alphabet, i don't know how you will have theregex
    for "english chars but not french or spanishones"
    :)Not true. Spanish has �
    KajAlso ll.ll was in 1994 dropped from the Spanish alphabet. :)No shit?
    What about ch and rr?

  • Creating a regex.Pattern for bulletin board tags

    I'm making a BB code system and have a problem making my patterns do as I like. At least when they are nested.
    For example, I'm using the this pattern:
    \\[b\\](.*?)\\[/b\\]And I'm replacing it with this:
    <b>{0}</b>If I apply this to the text:
    This is my text with bold words. Sometimes the tags [b]are nested[/b].It will turn into this (with a little cleaning.):
    This is my text with <b>bold</b> words. <b>Sometimes they are</b> nested.But what I really wanted, was this (with a little cleaning.):
    This is my text with <b>bold</b> words. <b>Sometimes they are nested</b>.I've tried a lot of different things, but always seems to run into a dead end. I'm hoping it's simply because I do not know enough about patterns, but I could really need some inspiration or guidance. Seems I'm running out of new things to try.
    Edited by: bsindu on Dec 5, 2007 1:44 AM

    It could be done using some replaceAll(...) operations:
    public class Foo {
        public static void main(String[] args) throws Exception {
            String text = "This is my text with bold words. Sometimes the tags [b]are nested[/b].";
            String s = text.
                        replaceAll("(\\[.\\][^\\[]+)\\[.\\]", "$1").    // replace the last tag of two successive 's
    replaceAll("\\[.\\]([^\\[]+\\[.\\])", "$1"). // replace the first tag of two successive 's
                        replaceAll("\\[(/?.)\\]", "<$1>");              // replace all and with <b> and </b>
            System.out.println(text);
            System.out.println(s);
    }Either a Pattern or a replaceAll(...) solution, both are a bit of a hack, if you ask me.

  • What patterns for this application???

    We have a large standalone C++ application which we are planning to port into java. Right now we are planning to port only the GUI (front end) part and retain the backend in C++ (Though, in the long long run we might even port the backend part to java but not right now). There are around 200 backend C++ programs.
    In simple terms the general architecture/functionality of the current C++ application is like this.
    Each front end screen will collects and passes the arguments to a common interface program
    The common interface program writes the arguments into a flat file and invokes corresponding backend C++ program
    The backend C++ program will read the arguments and generate an output file.
    Later the front end will read the output file, parse and display it graphically.
    If we want to retain the backend C++ programs for now, what is the general architecture that you would suggest and what Patterns should we consider to implement in the new version and how can they help?
    Thanks
    Raju

    I think you should reconsider your approach. Java excels as middleware. J2EE has been far more successful than any of the Java UI API's (AWT, Swing, SWT, etc.) So, in my mind, I would first convert the back-end to Java. I would probably leave the UI as C++, maybe indefinitely. Or switch the UI eventually to a J2EE web app.
    - Saish

  • Do I need a Singleton pattern for this case

    Hello,
    I'm writing a game in Java and I have a very simple score manager class which just tracks the points the player so far has. I need to access this class in different pars of my app (gui, game core ...) so I created a singleton class which looks like this
    public class ScoreManager {
            private static ScoreManager instance = new ScoreManager();
            private int score = 0;
         private int highScore = 0;
         public static ScoreManager getInstance() {
              return instance;
         public int getScore() {
              return score;
         public int getHighScore() {
              return highScore;
         public void addScore(int scoreToAdd){
              score += scoreToAdd;
              if(score > highScore) {
                   highScore = score;
    }so far so good ..
    I would like to read the "highScore" from a file when the game starts and write it back when the game ends. I added those two methods:
         public void init(File highScoreFile) {
              highScore = readFromFile(highScoreFile);
                    score = 0;               
         public void dispose(File highScoreFile) {
                   writeToFile(highScoreFile);
         }So basically I call the init() method when the game stars and the dispose() when the game ends.
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place.
    What would be a better way to do this ?
    Thanks for your help,
    Jesse

    safarmer wrote:
    You could keep track of the state (initialised, destroyed etc) in the manager and only perform the action if it is an expected state.
    private enum State { NOT_INITIALISED, INITIALISED, DESTROYED};
    private State currentState = State.NOT_INITIALISED;
    // i will leave the rest up to your imagination :) this looks good, thanks
    anotherAikman wrote:
    >
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. And who would that be? You´re the only one using the code, aren´t you?
    If not, you could still include in the documentation where to call those methods.
    no I'm not the only one working on this. Documentation can be useful but does not prevent calling wrong methods.
    YoungWinston wrote:
    I don't see any constructor. Usually, a singleton class should have a private one, even if it has no parameters. If you don't have any, Java will create a public no-parameter one as default.ok I forgot the private constructor.
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. Then my advice would be not to make them public. After all, your code is the only one calling these methods - yes?yes only the code of the app calls it.
    If you are convinced that your game requires one and only one score manager, then a singleton is probably the best way to go.
    I'm a little worried about the init() and dispose() methods though, because these suggest state changes, which is unusual for the singleton pattern. You may want to think about synchronizing them.
    An alternative might be to use properties to get and store your scores.ok for the synchronization. What would using the properties ? It would be just another type of storage backend and I'd still need to read/write it.
    Thanks for your help,
    J

  • Is there a design pattern for this situation?

    Hi,
    I'm making a survey engine. There is a Question class and a bunch of children of it (dropdown, checkbox, textbox, etc.). Now, correct me if i'm wrong, but I feel that this is a good case for inheritance. The problem I have is that Question needs to be initialized with parameters that the concrete question types have no business knowing about:
    //question constructor
    public Question(parameter1, parameter2, parameter3) {...}
    As a result, I am forced to require this as a parameter for all the concrete types since the Question requires these to be initialized:
    //checkbox constructor
    public Checkbox(parameterForQuestion1, parameterForQuestion2, parameterForQuestion3, parameterForMe1, parameterForMe2) {...}
    The checkbox doesn't directly use the first 3 parameters and I'd often prefer the the checkbox object doesn't have access to them. Because of this, i suspect a bad smell. Has anyone ever ran into this problem themselves? How did you solve it?
    Thanks,
    Dan

    tieTYT wrote:
    Yes, there's a bad smell, and it's coming from your proposed design.
    Separate the UI from your Survey and Question objects. Design the model and worry about the UI later.
    %You're assuming I didn't. Just because I'm using the word Checkbox and Dropdown doesn't mean I'm talking about UI components.I hope you didn't. If you actually did some analysis and came up with names like that for non-UI objects, your design is even smellier than I first thought
    A Checkbox has state like, "is box on right?" and "is checked". The Dropdown has state like, "currently selected option" and "list of options". The Question has state like, "am i invisible?", "what is my script", "am i enabled?". None of these classes have UI code in them. They just have names like this because, as you can see, there are fundamental differences between different question types that I use concrete children to sort out. With this setup I've already made a SWING and an AJAX frontend so I must be doing something right in the MVC department. No. I disagree that questions have states like "am I invisible?". That is irrelevant. A Question should not be aware that it is visible. Your design is very poor, I'm afraid, and it works by coincidence
    I'm making the assumption that you thought I wasn't doing this but if you still think this is a bad design, let me know. If not, please help me with my original question.It is, most definately, a bad design. Classes named for UI widgets, but that are not UI widgets? Terrible idea. Really, sickeningly awful. No offence.
    EDIT: And keep in mind this is a SURVEY engine. I specifically want to give the user of the library the power to specify whether their question is a Checkbox/Dropdown/RadioButtons/etc. In a normal application's code, the model wouldn't concern itself with details like, "Is this data going to be visualized as a checkbox?" But I feel that in this situation, the answer to that question actually does belong in the Model. But again, correct me if I'm wrong.
    Edited by: tieTYT on Oct 22, 2007 10:53 AMThe model should be entirely unaware of how it will be rendered. Siure, in this instance, you've decided to render a question as,say, a checkbox. What if you're generating a report on what questions there are? Presentation logic doesn't belong in the model, at all. You say "in a normal application" here, but, like it or not, this is a normal application. Everyone goes through a phase of thinking their own code is special, and different, and new, but it isn't. It's a pretty straightforward app as far as I can tell.
    Re-think your design. A class called Checkbox, that isn't a widget, stinks. Group UI concepts together, and use that as an abstraction. Dropdowns and radio buttons both present questions that can have exactly one correct answer out of a set. So you have a "MultipleChoice" question type. Then, in the UI layer, the decision can be made to render that question as a Dropdown or a bunch of radio buttons, without having to pollute your model with that.

  • Which pattern for this scenario ?

    Hi all,
    I have an EJB which connects to an external system (written in Perl) using plain HttpConnections and posting HTML content.
    I would like to centralize this access using a design pattern.
    Which pattern is would fit this scenario ?
    I wonder if I should use the Adapter pattern or the Bridge Pattern.
    What do you say to it ?
    Thanks
    Francesco

    I'd kind-of guessed it was uni work :-)
    in all honesty, I wouldn't even approach the problem from a patterns perspective. all I see is a subsystem I don't want to deal with directly, so I define an interface to hide it behind. could argue that it's an Adapter, since it's taking the Http interface and abstracting away from it, to a java one. on the other hand, since mucking around with Http in java isn't exactly straight-forward, you're defining a more simple interface, so it could be considered a facade. which do you think is closer?
    most people, once au fait with design patterns, think less in terms of those patterns, and more in terms of what OO principles to apply. score some extra credit by writing a passage about how design patterns are not prescriptive, and that many coders lift ideas about encapsulation and separation from patterns, rather than use the pattern exactly as described.

  • Please advise pattern for this situation

    Hi all,
    I plan to develop apps with thick client on the client side and using EJB on the server side, the EJB (Stateful Session Bean) will contain all the business logic and database connection.
    The apps are divided into multiple modules. Those modules can be used independently, but they can also be used in an integrated manner.
    So for example I develop Sales Invoicing module and Inventory module. If they're used together, each entry in Invoice will cut down the available Inventory automatically. But I also want to be able to sell Sales Invoicing module without dependency on Inventory module and vice versa.
    Question :
    1. Should I create separate Statefull Session Bean for each module (i.e EJBSalesInvoicing & EJBInventory) ?
    2. How can I detect the presence of another modules so that I can call their methods ?
    Any advice would be greatly appreciated
    Setya

    I am not sure if anybody can help you on designing the BUSINESS modules for Stateful SBs. But, we can suggest you the general overall architecture for THick Client Scenario.....
    How do u plan to connect to the Server?....are yoou using BMPs /JDOs...or are writing the JDBC connectivity directly inside Stateful Session Bean( wrong Design)?

  • Regex excluding a certain string

    Hi
    I have a question about how to search the strings that are in between a "start" and an "end". The results should not contain the word " cat ". All the strings with the format "start xxxxx yyyy end" that do not contain the word " cat " are valid. That is, the string "start XXX cat YYYY BBB end" should be rejected.
    I am using the regex "start(.*?)end" to find all the strings that start with "start" and ending with "end".
    The expression [^cat] can be used to negate the characters "cat" in any sequence (atc,act...). I want only to negate the sequence "cat". Any ideas about how to exclude the strings with "cat"in an effective way???
    Regards

    When you want to exclude whole
    sequences of characters, you have to use negative
    lookahead:
      String regex =
    "start\\s+((?!cat\\s+)\\S+\\s+)*?end";
    How does this regex work and where the "next search starts" in case the match fails because the string " cat " was found.
    We assume that there is a string "..startXXXVVVFF CC CAT xxx end......."
    This regex searches for the string "start" (in position a). When it finds "start" it starts "looking ahead" for the occurrence of " cat " (position a + 10). The string "end" is in position a+20. That is, it will find the string " cat " before it finds "end". It will discard the match. After discarding the "match" where does the regex starts searching for a new "start"?
    Does it start searching for a new match (sartXXXend)direct after the previous "start" (that is, at position a+1). Or does it starts searching after a new match after the previous "end" (at position a+21)????

Maybe you are looking for

  • Photoshop Elements 9 for Mac

    Does anyone know if Adobe is ever going to fix the time incrementing bug on Photoshop Elements 9 Organiser for Mac. If a file is edited, and the file was created before Daylight saving time and you are now on DST, the time is incremented forward by o

  • Daylight Savings issues on iCal

    My iCal is exactly an hour behind the posted system time on the device.  I live in Denver and have checked my settings and nothing seems to be weird...  I am confused, if the phone knows its currently 11:21am, why doesn't iCal use the sy

  • P67 GD65 B3 OC question

    Hi, I'm new into overclocking so pls be patient with me if I ask stupid questions. I have overclocked my i7 2600K to 4,2Ghz by changing the 1-4 core ratio limit to 42. All other settings are default. When I run Prime95 stress test the speed goes up t

  • Problem (strange line)

    Hi! I'm italian and i'm sorry for my english. I have a problem with the display of my MBP core 2 duo 2,2ghz with 10.5.1 (leopard). I post an image, so you can say something. http://www.flickr.com/photos/frenk/2515409167/ http://www.flickr.com/photos/

  • Hi my road runner mail works with mail but not outlook for mac?

    This problem seems to have popped up after updating to Lion.  I like outlook because I use it at work and I like the calander right there. My exchange account for work and gmail account function well but road runner is an issue?  Does any one have ex