My URL regex string for an entity field pattern fails
INFO! The JDL is being parsed.
error: Error message:
unexpected character: ->\<- at offset: 5572, skipped 1 characters.
SyntaxError: Error: unexpected character: ->\<- at offset: 5572, skipped 1 characters.
ERROR! Error while parsing applications and entities from the JDL SyntaxError: Error: unexpected character: ->\<- at offset: 5572, skipped 1 characters.
SyntaxError: Error: unexpected character: ->\<- at offset: 5572, skipped 1 characters.
at callApiMethod (/usr/local/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/reader/jdl_reader.js:88:11)
at parse (/usr/local/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/reader/jdl_reader.js:72:10)
at Object.parseFromFiles (/usr/local/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/reader/jdl_reader.js:41:10)
at parseFiles (/usr/local/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/jdl/jdl_importer.js:82:20)
at JDLImporter.import (/usr/local/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/jdl/jdl_importer.js:64:30)
at JDLProcessor.importJDL (/usr/local/lib/node_modules/generator-jhipster/cli/import-jdl.js:76:41)
at JDLProcessor.importJDL (/usr/local/lib/node_modules/generator-jhipster/cli/import-jdl.js:292:38)
at module.exports (/usr/local/lib/node_modules/generator-jhipster/cli/import-jdl.js:446:21)
at Command.<anonymous> (/usr/local/lib/node_modules/generator-jhipster/cli/cli.js:72:36)
at Command.listener (/usr/local/lib/node_modules/generator-jhipster/node_modules/commander/index.js:315:8)
##### **Motivation for or Use Case**
i try to regex for url's with the following, working regex string
`^(https?|ftp|file):\\/\\/[-a-zA-Z0-9+&@#\\/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#\\/%=~_|]$`
but the jdl parser throw an exception because auf the slashes. i try only forward slashes, escaping with one oder two backward slashes.
##### **Reproduce the error**
create an jdl file with the following entity
entity DummyEntity {
/** fieldName */
name String required,
website String pattern(/^(https?|ftp|file):\\/\\/[-a-zA-Z0-9+&@#\\/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#\\/%=~_|]$/),
email String pattern(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/),
}
##### **JHipster Version(s)**
i use jHipster version 6.0.0
##### **JHipster configuration**
`INFO! Using JHipster version installed globally
INFO! Executing jhipster:info
INFO! Options: from-cli: true
Welcome to the JHipster Information Sub-Generator
##### **JHipster Version(s)**
/Users/rizzi/Documents/WORK/EPBF/IdeaProjects/BitsButler
└── (empty)
cat: no such file or directory: .yo-rc.json
##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
entityName.json
files generated in the .jhipster
directory
JDL entity definitions
openjdk version "12" 2019-03-19
OpenJDK Runtime Environment (build 12+33)
OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)
git version 2.21.0
node: v12.1.0
npm: 6.9.0
yeoman: 2.0.5
yarn: 1.15.2
Docker version 18.09.2, build 6247962
docker-compose version 1.23.2, build 1110ad01
INFO! Congratulations, JHipster execution is complete!
`
no files generated
i use macOS 10.14.5
[X] Checking this box is mandatory (this is just to show you read everything)
I am with the same problem. I am using JHipster 6.0.1.
The pattern:
/[0-9]{2}\.?[0-9]{3}\.?[0-9]{3}\/?[0-9]{4}\-?[0-9]{2}/
The message that I was receiving is:
INFO! The JDL is being parsed.
error: Error message:
unexpected character: ->?<- at offset: 180, skipped 1 characters.
SyntaxError: Error: unexpected character: ->?<- at offset: 180, skipped 1 characters.
ERROR! Error while parsing applications and entities from the JDL SyntaxError: Error: unexpected character: ->?<- at offset: 180, skipped 1 characters.
SyntaxError: Error: unexpected character: ->?<- at offset: 180, skipped 1 characters.
at callApiMethod (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/node_modules/jhipster-core/lib/reader/jdl_reader.js:88:11)
at parse (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/node_modules/jhipster-core/lib/reader/jdl_reader.js:72:10)
at Object.parseFromFiles (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/node_modules/jhipster-core/lib/reader/jdl_reader.js:41:10)
at parseFiles (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/node_modules/jhipster-core/lib/jdl/jdl_importer.js:82:20)
at JDLImporter.import (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/node_modules/jhipster-core/lib/jdl/jdl_importer.js:64:30)
at JDLProcessor.importJDL (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/cli/import-jdl.js:76:41)
at JDLProcessor.importJDL (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/cli/import-jdl.js:292:38)
at module.exports (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/cli/import-jdl.js:446:21)
at Command.command.allowUnknownOption.description.action.args (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/cli/cli.js:72:36)
at Command.listener (/Users/viniciuscarvalho/Projects/sbt-platform/gateway/node_modules/generator-jhipster/node_modules/commander/index.js:315:8)
This is not the same error... But I'll try to find time to look into it
Apparently parsing a regexp, with a regexp, is like expecting too much of a regexp regexp-based parsing system.
Bottom line (without the joking): this is tricky. I'm trying solutions to get it working.
Most helpful comment
Apparently parsing a regexp, with a regexp, is like expecting too much of a regexp regexp-based parsing system.
Bottom line (without the joking): this is tricky. I'm trying solutions to get it working.