How to create a Regex for the NFS file system to use in angular pattern validations?
Asked
Active
Viewed 179 times
1 Answers
-1
^(?:[0-9]{1,3}\.){3}[0-9]{1,3}:(\/[a-zA-Z0-9_-]+)+$
You can use it like:
/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}:(\/[a-zA-Z0-9_-]+)+$/
This will help you match the following kind of pattern:
IP Address:Path
Example of IP address: 10.210.38.82
Example of Path: /opt/QuarantineFiles

RavinderSingh13
- 130,504
- 14
- 57
- 93

Shubham
- 167
- 2
- 9
-
1So, this only matches an IP? If the path is `DNS_NAME:/home` it wouldn't work? – VLAZ Aug 31 '21 at 06:22
-
My network drives all have names like: `gimli:/media` or `legolas:` or `gandalf:/public`. This validation will not work on my LAN – slebetman Aug 31 '21 at 06:56
-
@slebetman "Bug report: regex does not support Ring network architecture" :P – VLAZ Aug 31 '21 at 07:32
-
@VLAZ What do you suggest for hostnames like it can be an IP or it can be a hostname? – Shubham Aug 31 '21 at 12:25
-
@slebetman In any case you have proper IPs assigned, In case if you don't know IP or it is on localhost, We need to modify it so that it will check whether it should be an IP or it should be a hostname. Do you have any suggestions? – Shubham Aug 31 '21 at 12:27
-
@slebetman in any case I suggested one of the solutions to the problem. It's not accurate and isn't perfect. Help me make it perfect. – Shubham Aug 31 '21 at 12:28
-
My suggestion is to follow established standards and behave similar to all other network software like web browsers, FTP clients, ssh clients etc. Do not assume IP address - that's what professional software does. Just use `^([a-zA-Z0-9.\-]+):(\/[a-zA-Z0-9_-]+)+$`. Let your network layer handle hostname errors (usually with a no route to host error) – slebetman Aug 31 '21 at 13:11