[Python] How to identify randomly generated string in Python? [closed]

Discussão em 'Python' iniciado por Stack, Março 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list of strings, some of which contain random alphanumeric substrings that were not generated by a human. These random substrings are usually alphanumeric, but some valid substrings can also be alphanumeric.

    Example Input:

    "device-md-XYZ-P9LNKATxoghr",
    "logmonitoring-lambda-processor-3TGZQJDSFW7X-DedupTable",
    "net-sipproxy-config-RemoveSessionDialogProfile-A1JKV8PlmNQ5",
    "net-sipproxy-GtPXKHBa4z9m-config-SessionDialogProfileLifecycle",
    "user-analytics-tracking-analyticsGdprSearchProcess-QyPLXOWZBNH2",
    "testing-tracing-lambda-node@prod-monitor",
    "mlPipelineTrainingPy311ContainerLambdaFunction",
    "AcmeVendorProvisioning2025-b76c4f2d8ccd567208b3459a12f48e9e",
    "targetgroup/routing-LoadB-XYR3CTGF7KLP",
    "api-integration-service-mark-HookConfig",
    "acme-deploy-TerraformValidate",
    "cloudwatch-lambda-logger-LogAggregator"


    Expected Output:

    "device-md-XYZ",
    "logmonitoring-lambda-processor-DedupTable",
    "net-sipproxy-config-RemoveSessionDialogProfile",
    "net-sipproxy-config-SessionDialogProfileLifecycle",
    "user-analytics-tracking-analyticsGdprSearchProcess",
    "testing-tracing-lambda-node@prod-monitor",
    "mlPipelineTrainingPy311ContainerLambdaFunction",
    "AcmeVendorProvisioning2025",
    "targetgroup/routing-LoadB",
    "api-integration-service-mark-HookConfig",
    "acme-deploy-TerraformValidate",
    "cloudwatch-lambda-logger-LogAggregator",


    I attempted to use multiple regex patterns, but they didn’t work efficiently—some failed to detect. What would be an efficient way to detect and remove these random substrings in Python?

    Continue reading...

Compartilhe esta Página