#How to do regex

9 messages · Page 1 of 1 (latest)

wild vortex
#

So I have a function where I get a string y as an argument. Then I am supposed to write a regex that matches patterns. As in if the arg is prog then I am gonna match words that contain the alphabets in prog. It is not regex I am finding hard since I could write it if I knew the string. But I don't even know how to begin or what to do with a varible. I would really appreciate the help!

chilly pantherBOT
#

This post has been reserved for your question.

Hey @wild vortex! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

stray oracle
#

i dont entirely understand what your task is

chilly pantherBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

blissful sparrow
#

It really seems like a simple google request. However, here's what I found: https://www.w3schools.com/java/java_regex.asp

#

There is even an explanation of regex patterns and a short code snippet of how to use them in java:

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) {
    Pattern pattern = Pattern.compile("w3schools", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher("Visit W3Schools!");
    boolean matchFound = matcher.find();
    if(matchFound) {
      System.out.println("Match found");
    } else {
      System.out.println("Match not found");
    }
  }
}
// Outputs Match found
#

For other stuff I guess you can just read the javadocs of Pattern and Matcher classes

#

@wild vortex