In bash, using regex, check if a string is a commit ID
- User
In bash, using regex, check if a string is a commit ID
Assistant
# For full 40-character commit IDs if [[ $string =~ ^[0-9a-fA-F]{40}$ ]]; then echo "Valid commit ID" fi # For both full and shortened commit IDs (7-40 characters) if [[ $string =~ ^[0-9a-fA-F]{7,40}$ ]]; then echo "Valid commit ID" fiWould you like me to explain how this regex works?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.