Regular Expression - Omit Character
I have tried everything to get the below query to work. Checked every forum and help document (i.e https://regex101.com/ & http://www.mikesdotnetting.com/article/46/c-regular-expressions-cheat-sheet)
Goal:
"FRSTDIVID LIKE " + "'" + argState.ToString() + "%[0-9][0-9]%" + argTwn.ToString() + "0" + argNS.ToString() + argRng.ToString() + "0" + argEW.ToString() + "0SN" + argSec.ToString() + "What do I do here?" + "'"
Result Can Be:
FRSTDIVID LIKE 'LA[0-9][0-9]0010S0080W0SN09'
OR
FRSTDIVID LIKE 'LA[0-9][0-9]0010S0080W0SN090'
Depending on the State in the USA that darn "0" is there or not there so I am trying to variablize it via regular expressions like I did with the "[0-9][0-9]" for the Meridian.
4 hrs trying everything. Love/hate with regular expresions : (
0
-
You could use the substring function to strip of that last 'O': SUBSTRING(FRSTDIVID, 1, 19) LIKE 'LA[0-9][0-9]0010S0080W0SN09'0 -
yeah not sure if this is a bug against ArcGIS Server REST API on WHERE clause so I just did the classic "OR" statement. Life must go on but I feel like a half awesome person half idiot now with REGEX after trying everything under the sun.
Word of advice to someone trying REGEX in the future. Speed up your testing via the REST API: https://...../arcgis/rest/services/folder/mapserivce/MapServer/104/query <--I was sleepy and silly doing it the hard way by changing the REGEX testing in the Workflow itself...eye roll at myself.
"FRSTDIVID LIKE " + "'" + argState.ToString() + "[0-9][0-9]" + argTwn.ToString() + "0" + argNS.ToString() + argRng.ToString() + "0" + argEW.ToString() + "0" + "[SUP][NPBA]" + argSec.ToString() + "' OR FRSTDIVID LIKE " + "'" + argState.ToString() + "[0-9][0-9]" + argTwn.ToString() + "0" + argNS.ToString() + argRng.ToString() + "0" + argEW.ToString() + "0" + "[SUP][NPBA]" + argSec.ToString() + "0'"0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
2 kommentarer