const regex = /(interface [a-zA-Z0-9 <>,\.\/*?[\s]]* \{|(@Immutable|@ThreadSafe|@NotThreadSafe)(.*[\n])*.*(class|enum) [a-zA-Z0-9\s<>,\.\/*?]* \{)/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(interface [a-zA-Z0-9 <>,\\.\\\/*?[\\s]]* \\{|(@Immutable|@ThreadSafe|@NotThreadSafe)(.*[\\n])*.*(class|enum) [a-zA-Z0-9\\s<>,\\.\\\/*?]* \\{)', '')
const str = `package de.invesdwin.common.persistence.jpa.api.dao;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.concurrent.ThreadSafe;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ReflectionUtils.FieldCallback;
import de.invesdwin.common.lang.Assertions;
import de.invesdwin.common.lang.Reflections;
import de.invesdwin.common.persistence.jpa.PersistenceProperties;
import de.invesdwin.common.persistence.jpa.api.query.QueryConfig;
/**
* A DAO (DataAccessObject) is a special Repository that works for only one Entity. It implements default
* CRUD-Operations for it.
*
* JPA Entity attached/detaches status is automatically handled, so you don't need to care about that.
*
* @author subes
*/
@ThreadSafe
public abstract class ACustomIdDao<E, PK extends Serializable> extends ARepository implements IDao<E, PK> {
private final Class<E> genericType;
private final boolean deleteInBatchSupported;
private final QueryByExampleHelper<E, PK> queryByExampleHelper;
private Integer connectionBatchSize;
private SimpleJpaRepository<E, PK> delegate;
private String persistenceUnitName;
}
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions