425 reputation
312
bio website
location
age
visits member for 2 years, 6 months
seen yesterday

1d
comment grep variable-length optional text
Yes, the attempt can be enjoyable as a thought exercise, though in the end, our goal as a programmer, as you have noted, must be efficiency.
1d
accepted grep variable-length optional text
1d
comment grep variable-length optional text
You make an excellent point. I was operating under the impression that a regex equivalent to the family would be the most elegant solution, but failed to appreciate that constructing the family as a set of string literals would be computationally much less expensive, and moreover that the difference in computational overhead between the two approaches would scale with the size of the file to be examined.
1d
awarded  Custodian
1d
reviewed Approve suggested edit on grep variable-length optional text
1d
comment grep variable-length optional text
Out of curiosity, do you know if it is possible to formulate the search in the language of regular expressions (i.e., can one construct a regex that equates to the family of search queries)? Or is the only solution to build the family of queries programmatically, as you have done?
1d
comment grep variable-length optional text
Oh, that's an interesting solution: constructing the entire list of valid sequences and submitting all of them to grep. I was thinking of building a regex that represented the valid list, but simply searching for each individually would work equally well. Thanks.
1d
revised grep variable-length optional text
clarification of the problem in response to a submitted answer
1d
comment grep variable-length optional text
The problem is that it would also return, for example, ^axyz, which is undesired.
1d
comment grep variable-length optional text
@steeldriver: This is because the preceding sequence is definite. For instance, I would not want to count ZKEJLCN as a valid result. If the file consists only of capital letters, then grep '^[A-Z]*KEJLCN' is equivalent to grep KEJLCN.
1d
revised grep variable-length optional text
added a more detailed example
1d
awarded  Yearling
1d
comment grep variable-length optional text
I added a more detailed example. Please let me know if that clarifies the matter. Thanks.
1d
revised grep variable-length optional text
added a more detailed example
1d
asked grep variable-length optional text
1d
asked agrep with directionally biased penalties
Jul
6
revised automatic disconnection of RAID array
added 5513 characters in body
Jul
2
awarded  Curious
Jun
24
awarded  Tumbleweed
Jun
22
asked automatic disconnection of RAID array