November Happy Hour will be moved to Thursday December 5th.

Regular expression isnt working as expected on one of the fields in block

Vote:
 

Hi,

I am attempting to create a regular expression for one of the fields in my component block however it doesnt seem to be working. the field needs to accept forward slashes

  [Display(Name = "Theme",
            Description = "Choose from pre-defined Theme",
            GroupName = TabNames.CampaignSettings,
            Order = 10)]
        [AutoSuggestSelection(typeof(BrandThemeSelectionFactory))]
        [RegularExpression(@"^[a-zA-Z0-9\s/]*$")]
        [CultureSpecific]
        public virtual string Theme { get; set; }

Does anyone know what im doing wrong here?

Thanks

#307687
Edited, Aug 30, 2023 16:24
Vote:
 

How do you mean it "doesn't seem to be working"? It should only allow ContentReference so / is not allowed even if you have regex allow it

#307723
Aug 31, 2023 5:59
Vote:
 

Hi quan, my apologies, i posted the wrong code! I've updated my post again and replaced it with the correct field. There is a drop down list in the campaign settings, and when i select one of the string theme names, and publish the  page, the drop down list appears empty instead of being populated.

#307730
Edited, Aug 31, 2023 9:43
Vote:
 

I'd use an enum property.. much cleaner. Only works if your Themes are really very predefined of course. 

#307807
Sep 01, 2023 0:50
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.