The official RegexSolver libraries send their requests through a client. Java and Python each ship a synchronous client and an asynchronous one; JavaScript ships a single client, and it is asynchronous. This page shows how to use each of them.
In Java, you can choose between RegexSolverClient (synchronous) and AsyncRegexSolverClient (asynchronous).
Synchronous
Code
import com.regexsolver.api.RegexSolverClient;import com.regexsolver.api.Term;import com.regexsolver.api.exceptions.ApiException;public class Main { public static void main(String[] args) throws ApiException { RegexSolverClient client = RegexSolverClient.builder() .apiToken(System.getenv("REGEXSOLVER_API_TOKEN")) .build(); Term a = Term.regex("abc"); Term b = Term.regex("def"); Term result = client.union(a, b); System.out.println(result); }}
Asynchronous
Code
import com.regexsolver.api.AsyncRegexSolverClient;import com.regexsolver.api.Term;import com.regexsolver.api.exceptions.ApiException;import java.util.concurrent.CompletableFuture;public class Main { public static void main(String[] args) throws ApiException { AsyncRegexSolverClient client = AsyncRegexSolverClient.builder() .apiToken(System.getenv("REGEXSOLVER_API_TOKEN")) .build(); Term a = Term.regex("abc"); Term b = Term.regex("def"); // Returns a CompletableFuture<Term> client.union(a, b) .thenAccept(result -> System.out.println("Union: " + result)); }}