In a property storage function, the Excel attribute data is imported into the layer features, there is an associated field in Excel and the SDE database data, and the matching attribute is put into storage by the associated field value.
In the actual business, because the census data often some field value is more complex, the user may make some simplification when writing to the layer, for example a feature number is 0532bh001, may enter into the layer only enters the BH001, This results in the values of the layer features and Excel file association fields that are not necessarily exactly equal, and there may be some matching relationships.
This does not take into account the complexity of the case, only considering that the value of the associated field in Excel is the case where the feature associated field value is prefixed, suffixed, or prepended.
Because Excel is used as a benchmark for looping, after constructing a field value and then using the query operation in the layer to find the corresponding feature, you cannot determine the processing by removing the value of the field in the Layer Feature association field and then by connecting the prefix. Can only be handled by intercepting the associated field values in Excel.
According to the actual situation here, the format is fixed, the removal of the prefix, suffix function as follows:
///<summary> ///Remove prefix string///</summary>///<param name= "val" >Original String</param>///<param name= "str" >prefix string</param> ///<returns></returns>Private stringGetremoveprefixstring (stringValstringstr) { stringStrregex =@"^("+ str +")"; returnRegex.Replace (Val, Strregex,""); } ///<summary> ///Remove suffix string///</summary> ///<param name= "val" >Original String</param> ///<param name= "str" >suffix string</param> ///<returns></returns> Private stringGetremovesuffixstring (stringValstringstr) { stringStrregex =@"("+ str +")"+"$"; returnRegex.Replace (Val, Strregex,""); }
Extension, if the string requirements are not so strict, but simply to intercept the string before and after, then you can do this way:
///<summary>///string before and after truncation///</summary> ///<param name= "val" >Original String</param>///<param name= "str" >the string to cut off</param>///<param name= "Ballstr" >whether to intercept the entire string///If true, intercepts the entire string for matching///If False, only the prefix or suffix is truncated</param>///<returns></returns>Private stringGetString (stringValstringStrBOOLballstr) { returnRegex.Replace (Val,@"(^("+ str +")"+ (ballstr?)"*":"") +"| ("+ str +")"+ (ballstr?)"*":"") +"$)","");}
If you are intercepting a single character instead of a string, you can do so by using the TrimStart or TrimEnd function:
/// <summary>///pre-and post-truncation characters/// </summary>/// <param name= "val" >Original String</param>/// <param name= "C" >the characters to intercept</param>/// <returns></returns>Private stringGetString (stringValCharc) { returnval. TrimStart (c). TrimEnd (c); }
The above motion diagram is provided by "graph bucket"
C # Remove string Kinsoku or string