Ignore before and after word

Discussion in 'Plugin Development' started by sionzee, Feb 17, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    sionzee

    How I do this ? (TOPIC NAME)

    Code:java
    1. msg = msg.replaceAll("(?i)kyll", "kill");


    I tested this:

    Code:java
    1. msg = msg.replaceAll("//(?i)kyll//", "kill");


    Without results
     
  2. Offline

    Ugleh

    Your looking for help with Regular Expression, which is not what this forum is used for. Id suggest next time you use a different source for asking questions that are java related and not Bukkit related.
    I find for Java (and many other languages) a great place to ask a question and get a fast response is StackOverflow.

    Now, to answer your question... I do not understand what you want. Is the msg going to be 3 words and you just want the middle?
     
  3. Offline

    sionzee

    when he say: akyll (replace doesn't work)
    Because only checking kyll, i need ignore all before and after this word.
    wefwgwkyllgwegwe = wefwgwkillgwegwe
     
  4. Offline

    Ugleh

    You dont need to actually use regex unless you need it in the parameter. So you can do this
    .replaceAll("kyll", "kill");
     
  5. Offline

    sionzee

    without (?i) when he say KyLL doesn't replace... on msg equalsIgnoreCase doesn't work.
    Alternative solution ?
     
  6. Offline

    Score_Under

    Code:
    private static final Pattern shesAKyllerQueen = Pattern.compile("kyll", Pattern.LITERAL | Pattern.CASE_INSENSITIVE);
    //...
    msg = shesAKyllerQueen.matcher(msg).replaceAll("kill"); 
     
Thread Status:
Not open for further replies.

Share This Page