我想识别两个带有加号的字符串,但加号可以带或不带前导和/或尾随空格...... 示例:
tree + bowl
或
flower+sun
或
disk+ drive
或
large +database
任何想法?
答案 0 :(得分:1)
试试\w+ ?\+ ?\w+
。它使用?
quantifier使前一个令牌与之匹配可选。
如果可能有多个空格,您可以尝试\w+ *\+ *\w+
,因为[Table("Employees")]
public class Employee
{
#region Main Properties
// This value is generated by our LDAP user system and input manually during Employee creation in the new system.
[Key, Required, StringLength(20), DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Name = "LDAP / Global ID")]
public string LdapID { get; set; }
[Required, StringLength(50)]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Required, StringLength(50)]
[Display(Name = "Last Name")]
public string LastName { get; set; }
[StringLength(35)]
public string Department { get; set; }
[StringLength(50), DataType(DataType.EmailAddress)]
public string Email { get; set; }
[Display(Name = "Work Phone"), DisplayFormat(DataFormatString = "{0:(###) ###-####}", ApplyFormatInEditMode = false)]
public long? WorkPhone { get; set; }
[Display(Name = "Mobile Phone"), DisplayFormat(DataFormatString = "{0:(###) ###-####}", ApplyFormatInEditMode = false)]
public long? MobilePhone { get; set; }
[StringLength(20)]
[Display(Name = "Fax Number")]
public string Fax { get; set; }
[StringLength(20)]
[Display(Name = "Mail Stop")]
public string MailStop { get; set; }
[DataType(DataType.DateTime)]
[Display(Name = "Last Login"), DisplayFormat(DataFormatString = "{0:d MMM yyyy h:mm tt} UTC", ApplyFormatInEditMode = true)]
public DateTime? LastLogin { get; set; }
/// <summary>
/// Used to modify security permissions for the user.
/// <para>Possible values are: 0 - Disabled, 1 - Read Only, 2 - Read/Write, 3 - Loan Admin, 4 - Super Admin</para>
/// </summary>
[Display(Name = "Access Level")]
public AccessType AccessLevel { get; set; }
/// <summary>
/// This property is used for concurrency, to prevent two users from submitting conflicting updates.
/// </summary>
[Timestamp]
public byte[] Timestamp { get; set; }
#endregion
#region Navigation Properties
[Display(Name = "Responsible Companies")]
public virtual ICollection<Company> ResponsibleCompanies { get; set; }
[InverseProperty("Employee")]
[Display(Name = "History")]
public virtual ICollection<History> History { get; set; }
#endregion
#region Unmapped Properties
/// <summary>
/// Returns the user's full name in the format: Lastname, Firstname
/// </summary>
[NotMapped]
[Display(Name = "Full Name")]
public string FullName => $"{LastName}, {FirstName}";
#endregion
}
在零和无限次之间匹配前一个标记。